From 5e73e6593f0d079ceb2b2400df7f50586cca3b70 Mon Sep 17 00:00:00 2001 From: Tamir Duberstein Date: Sat, 25 Oct 2025 16:09:00 -0400 Subject: [PATCH 1/5] rename `rustc_target::spec::abi_map::Arch{,Kind}` This makes way for `rustc_target::spec::Arch`. --- compiler/rustc_target/src/spec/abi_map.rs | 74 ++++++++++++----------- 1 file changed, 38 insertions(+), 36 deletions(-) diff --git a/compiler/rustc_target/src/spec/abi_map.rs b/compiler/rustc_target/src/spec/abi_map.rs index 23e74539ddc07..5370903d0d6ae 100644 --- a/compiler/rustc_target/src/spec/abi_map.rs +++ b/compiler/rustc_target/src/spec/abi_map.rs @@ -8,7 +8,7 @@ use crate::spec::Target; /// encapsulating arch-specific ABI lowering details to make them more testable. #[derive(Clone, Debug)] pub struct AbiMap { - arch: Arch, + arch: ArchKind, os: OsKind, } @@ -48,17 +48,17 @@ impl AbiMap { pub fn from_target(target: &Target) -> Self { // the purpose of this little exercise is to force listing what affects these mappings let arch = match &*target.arch { - "aarch64" => Arch::Aarch64, - "amdgpu" => Arch::Amdgpu, - "arm" if target.llvm_target.starts_with("thumbv8m") => Arch::Arm(ArmVer::ThumbV8M), - "arm" => Arch::Arm(ArmVer::Other), - "avr" => Arch::Avr, - "msp430" => Arch::Msp430, - "nvptx64" => Arch::Nvptx, - "riscv32" | "riscv64" => Arch::Riscv, - "x86" => Arch::X86, - "x86_64" => Arch::X86_64, - _ => Arch::Other, + "aarch64" => ArchKind::Aarch64, + "amdgpu" => ArchKind::Amdgpu, + "arm" if target.llvm_target.starts_with("thumbv8m") => ArchKind::Arm(ArmVer::ThumbV8M), + "arm" => ArchKind::Arm(ArmVer::Other), + "avr" => ArchKind::Avr, + "msp430" => ArchKind::Msp430, + "nvptx64" => ArchKind::Nvptx, + "riscv32" | "riscv64" => ArchKind::Riscv, + "x86" => ArchKind::X86, + "x86_64" => ArchKind::X86_64, + _ => ArchKind::Other, }; let os = if target.is_like_windows { @@ -87,10 +87,12 @@ impl AbiMap { (ExternAbi::Custom, _) => CanonAbi::Custom, - (ExternAbi::System { .. }, Arch::X86) if os == OsKind::Windows && !has_c_varargs => { + (ExternAbi::System { .. }, ArchKind::X86) + if os == OsKind::Windows && !has_c_varargs => + { CanonAbi::X86(X86Call::Stdcall) } - (ExternAbi::System { .. }, Arch::Arm(..)) if self.os == OsKind::VEXos => { + (ExternAbi::System { .. }, ArchKind::Arm(..)) if self.os == OsKind::VEXos => { // Calls to VEXos APIs do not use VFP registers. CanonAbi::Arm(ArmCall::Aapcs) } @@ -101,19 +103,19 @@ impl AbiMap { // always and forever (ExternAbi::RustInvalid, _) => return AbiMapping::Invalid, - (ExternAbi::EfiApi, Arch::Arm(..)) => CanonAbi::Arm(ArmCall::Aapcs), - (ExternAbi::EfiApi, Arch::X86_64) => CanonAbi::X86(X86Call::Win64), - (ExternAbi::EfiApi, Arch::Aarch64 | Arch::Riscv | Arch::X86) => CanonAbi::C, + (ExternAbi::EfiApi, ArchKind::Arm(..)) => CanonAbi::Arm(ArmCall::Aapcs), + (ExternAbi::EfiApi, ArchKind::X86_64) => CanonAbi::X86(X86Call::Win64), + (ExternAbi::EfiApi, ArchKind::Aarch64 | ArchKind::Riscv | ArchKind::X86) => CanonAbi::C, (ExternAbi::EfiApi, _) => return AbiMapping::Invalid, /* arm */ - (ExternAbi::Aapcs { .. }, Arch::Arm(..)) => CanonAbi::Arm(ArmCall::Aapcs), + (ExternAbi::Aapcs { .. }, ArchKind::Arm(..)) => CanonAbi::Arm(ArmCall::Aapcs), (ExternAbi::Aapcs { .. }, _) => return AbiMapping::Invalid, - (ExternAbi::CmseNonSecureCall, Arch::Arm(ArmVer::ThumbV8M)) => { + (ExternAbi::CmseNonSecureCall, ArchKind::Arm(ArmVer::ThumbV8M)) => { CanonAbi::Arm(ArmCall::CCmseNonSecureCall) } - (ExternAbi::CmseNonSecureEntry, Arch::Arm(ArmVer::ThumbV8M)) => { + (ExternAbi::CmseNonSecureEntry, ArchKind::Arm(ArmVer::ThumbV8M)) => { CanonAbi::Arm(ArmCall::CCmseNonSecureEntry) } (ExternAbi::CmseNonSecureCall | ExternAbi::CmseNonSecureEntry, ..) => { @@ -121,53 +123,53 @@ impl AbiMap { } /* gpu */ - (ExternAbi::PtxKernel, Arch::Nvptx) => CanonAbi::GpuKernel, - (ExternAbi::GpuKernel, Arch::Amdgpu | Arch::Nvptx) => CanonAbi::GpuKernel, + (ExternAbi::PtxKernel, ArchKind::Nvptx) => CanonAbi::GpuKernel, + (ExternAbi::GpuKernel, ArchKind::Amdgpu | ArchKind::Nvptx) => CanonAbi::GpuKernel, (ExternAbi::PtxKernel | ExternAbi::GpuKernel, _) => return AbiMapping::Invalid, /* x86 */ - (ExternAbi::Cdecl { .. }, Arch::X86) => CanonAbi::C, + (ExternAbi::Cdecl { .. }, ArchKind::X86) => CanonAbi::C, (ExternAbi::Cdecl { .. }, _) => return AbiMapping::Deprecated(CanonAbi::C), - (ExternAbi::Fastcall { .. }, Arch::X86) => CanonAbi::X86(X86Call::Fastcall), + (ExternAbi::Fastcall { .. }, ArchKind::X86) => CanonAbi::X86(X86Call::Fastcall), (ExternAbi::Fastcall { .. }, _) if os == OsKind::Windows => { return AbiMapping::Deprecated(CanonAbi::C); } (ExternAbi::Fastcall { .. }, _) => return AbiMapping::Invalid, - (ExternAbi::Stdcall { .. }, Arch::X86) => CanonAbi::X86(X86Call::Stdcall), + (ExternAbi::Stdcall { .. }, ArchKind::X86) => CanonAbi::X86(X86Call::Stdcall), (ExternAbi::Stdcall { .. }, _) if os == OsKind::Windows => { return AbiMapping::Deprecated(CanonAbi::C); } (ExternAbi::Stdcall { .. }, _) => return AbiMapping::Invalid, - (ExternAbi::Thiscall { .. }, Arch::X86) => CanonAbi::X86(X86Call::Thiscall), + (ExternAbi::Thiscall { .. }, ArchKind::X86) => CanonAbi::X86(X86Call::Thiscall), (ExternAbi::Thiscall { .. }, _) => return AbiMapping::Invalid, - (ExternAbi::Vectorcall { .. }, Arch::X86 | Arch::X86_64) => { + (ExternAbi::Vectorcall { .. }, ArchKind::X86 | ArchKind::X86_64) => { CanonAbi::X86(X86Call::Vectorcall) } (ExternAbi::Vectorcall { .. }, _) => return AbiMapping::Invalid, - (ExternAbi::SysV64 { .. }, Arch::X86_64) => CanonAbi::X86(X86Call::SysV64), - (ExternAbi::Win64 { .. }, Arch::X86_64) => CanonAbi::X86(X86Call::Win64), + (ExternAbi::SysV64 { .. }, ArchKind::X86_64) => CanonAbi::X86(X86Call::SysV64), + (ExternAbi::Win64 { .. }, ArchKind::X86_64) => CanonAbi::X86(X86Call::Win64), (ExternAbi::SysV64 { .. } | ExternAbi::Win64 { .. }, _) => return AbiMapping::Invalid, /* interrupts */ - (ExternAbi::AvrInterrupt, Arch::Avr) => CanonAbi::Interrupt(InterruptKind::Avr), - (ExternAbi::AvrNonBlockingInterrupt, Arch::Avr) => { + (ExternAbi::AvrInterrupt, ArchKind::Avr) => CanonAbi::Interrupt(InterruptKind::Avr), + (ExternAbi::AvrNonBlockingInterrupt, ArchKind::Avr) => { CanonAbi::Interrupt(InterruptKind::AvrNonBlocking) } - (ExternAbi::Msp430Interrupt, Arch::Msp430) => { + (ExternAbi::Msp430Interrupt, ArchKind::Msp430) => { CanonAbi::Interrupt(InterruptKind::Msp430) } - (ExternAbi::RiscvInterruptM, Arch::Riscv) => { + (ExternAbi::RiscvInterruptM, ArchKind::Riscv) => { CanonAbi::Interrupt(InterruptKind::RiscvMachine) } - (ExternAbi::RiscvInterruptS, Arch::Riscv) => { + (ExternAbi::RiscvInterruptS, ArchKind::Riscv) => { CanonAbi::Interrupt(InterruptKind::RiscvSupervisor) } - (ExternAbi::X86Interrupt, Arch::X86 | Arch::X86_64) => { + (ExternAbi::X86Interrupt, ArchKind::X86 | ArchKind::X86_64) => { CanonAbi::Interrupt(InterruptKind::X86) } ( @@ -186,7 +188,7 @@ impl AbiMap { } #[derive(Debug, PartialEq, Copy, Clone)] -enum Arch { +enum ArchKind { Aarch64, Amdgpu, Arm(ArmVer), From cf053b37749a98e8e5ebcc63952aa9a232689316 Mon Sep 17 00:00:00 2001 From: Tamir Duberstein Date: Sat, 25 Oct 2025 16:20:58 -0400 Subject: [PATCH 2/5] rustc_target::spec::base::apple: nix `use Arch::*` This will reduce ambiguity with `rustc_target::spec::Arch`. --- .../rustc_target/src/spec/base/apple/mod.rs | 59 ++++++++++--------- 1 file changed, 32 insertions(+), 27 deletions(-) diff --git a/compiler/rustc_target/src/spec/base/apple/mod.rs b/compiler/rustc_target/src/spec/base/apple/mod.rs index c32e333eb8b02..8f0b9a4517f92 100644 --- a/compiler/rustc_target/src/spec/base/apple/mod.rs +++ b/compiler/rustc_target/src/spec/base/apple/mod.rs @@ -11,7 +11,6 @@ use crate::spec::{ #[cfg(test)] mod tests; -use Arch::*; #[allow(non_camel_case_types)] #[derive(Copy, Clone, PartialEq)] pub(crate) enum Arch { @@ -29,54 +28,60 @@ pub(crate) enum Arch { impl Arch { fn target_name(self) -> &'static str { match self { - Armv7k => "armv7k", - Armv7s => "armv7s", - Arm64 => "arm64", - Arm64e => "arm64e", - Arm64_32 => "arm64_32", - I386 => "i386", - I686 => "i686", - X86_64 => "x86_64", - X86_64h => "x86_64h", + Self::Armv7k => "armv7k", + Self::Armv7s => "armv7s", + Self::Arm64 => "arm64", + Self::Arm64e => "arm64e", + Self::Arm64_32 => "arm64_32", + Self::I386 => "i386", + Self::I686 => "i686", + Self::X86_64 => "x86_64", + Self::X86_64h => "x86_64h", } } pub(crate) fn target_arch(self) -> Cow<'static, str> { Cow::Borrowed(match self { - Armv7k | Armv7s => "arm", - Arm64 | Arm64e | Arm64_32 => "aarch64", - I386 | I686 => "x86", - X86_64 | X86_64h => "x86_64", + Self::Armv7k | Self::Armv7s => "arm", + Self::Arm64 | Self::Arm64e | Self::Arm64_32 => "aarch64", + Self::I386 | Self::I686 => "x86", + Self::X86_64 | Self::X86_64h => "x86_64", }) } fn target_cpu(self, env: TargetEnv) -> &'static str { match self { - Armv7k => "cortex-a8", - Armv7s => "swift", // iOS 10 is only supported on iPhone 5 or higher. - Arm64 => match env { + Self::Armv7k => "cortex-a8", + Self::Armv7s => "swift", // iOS 10 is only supported on iPhone 5 or higher. + Self::Arm64 => match env { TargetEnv::Normal => "apple-a7", TargetEnv::Simulator => "apple-a12", TargetEnv::MacCatalyst => "apple-a12", }, - Arm64e => "apple-a12", - Arm64_32 => "apple-s4", + Self::Arm64e => "apple-a12", + Self::Arm64_32 => "apple-s4", // Only macOS 10.12+ is supported, which means // all x86_64/x86 CPUs must be running at least penryn // https://github.com/llvm/llvm-project/blob/01f924d0e37a5deae51df0d77e10a15b63aa0c0f/clang/lib/Driver/ToolChains/Arch/X86.cpp#L79-L82 - I386 | I686 => "penryn", - X86_64 => "penryn", + Self::I386 | Self::I686 => "penryn", + Self::X86_64 => "penryn", // Note: `core-avx2` is slightly more advanced than `x86_64h`, see // comments (and disabled features) in `x86_64h_apple_darwin` for // details. It is a higher baseline then `penryn` however. - X86_64h => "core-avx2", + Self::X86_64h => "core-avx2", } } fn stack_probes(self) -> StackProbeType { match self { - Armv7k | Armv7s => StackProbeType::None, - Arm64 | Arm64e | Arm64_32 | I386 | I686 | X86_64 | X86_64h => StackProbeType::Inline, + Self::Armv7k | Self::Armv7s => StackProbeType::None, + Self::Arm64 + | Self::Arm64e + | Self::Arm64_32 + | Self::I386 + | Self::I686 + | Self::X86_64 + | Self::X86_64h => StackProbeType::Inline, } } } @@ -132,10 +137,10 @@ pub(crate) fn base( default_dwarf_version: 4, frame_pointer: match arch { // clang ignores `-fomit-frame-pointer` for Armv7, it only accepts `-momit-leaf-frame-pointer` - Armv7k | Armv7s => FramePointer::Always, + Arch::Armv7k | Arch::Armv7s => FramePointer::Always, // clang supports omitting frame pointers for the rest, but... don't? - Arm64 | Arm64e | Arm64_32 => FramePointer::NonLeaf, - I386 | I686 | X86_64 | X86_64h => FramePointer::Always, + Arch::Arm64 | Arch::Arm64e | Arch::Arm64_32 => FramePointer::NonLeaf, + Arch::I386 | Arch::I686 | Arch::X86_64 | Arch::X86_64h => FramePointer::Always, }, has_rpath: true, dll_suffix: ".dylib".into(), From 270e49b3072fe03ea388ebbb76e0eee80ee27565 Mon Sep 17 00:00:00 2001 From: Tamir Duberstein Date: Mon, 13 Oct 2025 12:41:24 -0400 Subject: [PATCH 3/5] rustc_target: introduce Arch Improve type safety by using an enum rather than strings. --- .../src/attributes/link_attrs.rs | 4 +- .../rustc_codegen_cranelift/src/abi/mod.rs | 17 +- .../src/codegen_f16_f128.rs | 10 +- .../rustc_codegen_cranelift/src/common.rs | 4 +- compiler/rustc_codegen_cranelift/src/lib.rs | 23 +-- compiler/rustc_codegen_gcc/src/abi.rs | 20 +- compiler/rustc_codegen_gcc/src/attributes.rs | 8 +- compiler/rustc_codegen_gcc/src/base.rs | 4 +- compiler/rustc_codegen_gcc/src/context.rs | 2 +- compiler/rustc_codegen_gcc/src/gcc_util.rs | 68 ++++--- compiler/rustc_codegen_gcc/src/lib.rs | 4 +- compiler/rustc_codegen_llvm/src/abi.rs | 17 +- compiler/rustc_codegen_llvm/src/attributes.rs | 8 +- compiler/rustc_codegen_llvm/src/back/write.rs | 6 +- compiler/rustc_codegen_llvm/src/builder.rs | 11 +- compiler/rustc_codegen_llvm/src/callee.rs | 3 +- compiler/rustc_codegen_llvm/src/consts.rs | 3 +- compiler/rustc_codegen_llvm/src/context.rs | 18 +- compiler/rustc_codegen_llvm/src/llvm_util.rs | 183 ++++++++++-------- compiler/rustc_codegen_llvm/src/mono_item.rs | 4 +- compiler/rustc_codegen_llvm/src/va_arg.rs | 37 ++-- compiler/rustc_codegen_ssa/src/back/apple.rs | 6 +- .../rustc_codegen_ssa/src/back/archive.rs | 43 ++-- compiler/rustc_codegen_ssa/src/back/link.rs | 3 +- .../src/back/link/raw_dylib.rs | 3 +- compiler/rustc_codegen_ssa/src/back/linker.rs | 16 +- .../src/back/symbol_export.rs | 10 +- compiler/rustc_codegen_ssa/src/base.rs | 7 +- .../rustc_codegen_ssa/src/mir/intrinsic.rs | 3 +- .../rustc_codegen_ssa/src/mir/naked_asm.rs | 4 +- .../rustc_codegen_ssa/src/target_features.rs | 3 +- compiler/rustc_metadata/src/native_libs.rs | 4 +- compiler/rustc_middle/src/ty/context.rs | 2 +- compiler/rustc_session/src/config/cfg.rs | 4 +- compiler/rustc_session/src/session.rs | 18 +- compiler/rustc_target/src/asm/mod.rs | 65 +++---- compiler/rustc_target/src/callconv/mod.rs | 66 ++++--- compiler/rustc_target/src/spec/abi_map.rs | 27 +-- .../rustc_target/src/spec/base/apple/mod.rs | 34 ++-- .../rustc_target/src/spec/base/nto_qnx.rs | 4 +- compiler/rustc_target/src/spec/json.rs | 4 +- compiler/rustc_target/src/spec/mod.rs | 137 ++++++++----- .../spec/targets/aarch64_be_unknown_hermit.rs | 4 +- .../targets/aarch64_be_unknown_linux_gnu.rs | 6 +- .../aarch64_be_unknown_linux_gnu_ilp32.rs | 6 +- .../targets/aarch64_be_unknown_linux_musl.rs | 4 +- .../spec/targets/aarch64_be_unknown_netbsd.rs | 4 +- .../aarch64_be_unknown_none_softfloat.rs | 4 +- .../spec/targets/aarch64_kmc_solid_asp3.rs | 4 +- .../src/spec/targets/aarch64_linux_android.rs | 4 +- .../aarch64_nintendo_switch_freestanding.rs | 4 +- .../targets/aarch64_pc_windows_gnullvm.rs | 4 +- .../spec/targets/aarch64_pc_windows_msvc.rs | 4 +- .../spec/targets/aarch64_unknown_freebsd.rs | 6 +- .../spec/targets/aarch64_unknown_fuchsia.rs | 4 +- .../spec/targets/aarch64_unknown_helenos.rs | 4 +- .../spec/targets/aarch64_unknown_hermit.rs | 4 +- .../spec/targets/aarch64_unknown_illumos.rs | 4 +- .../spec/targets/aarch64_unknown_linux_gnu.rs | 4 +- .../aarch64_unknown_linux_gnu_ilp32.rs | 6 +- .../targets/aarch64_unknown_linux_musl.rs | 4 +- .../targets/aarch64_unknown_linux_ohos.rs | 4 +- .../targets/aarch64_unknown_managarm_mlibc.rs | 4 +- .../spec/targets/aarch64_unknown_netbsd.rs | 4 +- .../src/spec/targets/aarch64_unknown_none.rs | 4 +- .../targets/aarch64_unknown_none_softfloat.rs | 4 +- .../src/spec/targets/aarch64_unknown_nuttx.rs | 4 +- .../spec/targets/aarch64_unknown_openbsd.rs | 4 +- .../src/spec/targets/aarch64_unknown_redox.rs | 4 +- .../src/spec/targets/aarch64_unknown_teeos.rs | 4 +- .../spec/targets/aarch64_unknown_trusty.rs | 5 +- .../src/spec/targets/aarch64_unknown_uefi.rs | 4 +- .../spec/targets/aarch64_uwp_windows_msvc.rs | 4 +- .../src/spec/targets/aarch64_wrs_vxworks.rs | 4 +- .../src/spec/targets/amdgcn_amd_amdhsa.rs | 6 +- .../spec/targets/arm64ec_pc_windows_msvc.rs | 6 +- .../src/spec/targets/arm_linux_androideabi.rs | 4 +- .../spec/targets/arm_unknown_linux_gnueabi.rs | 4 +- .../targets/arm_unknown_linux_gnueabihf.rs | 4 +- .../targets/arm_unknown_linux_musleabi.rs | 4 +- .../targets/arm_unknown_linux_musleabihf.rs | 4 +- .../targets/armeb_unknown_linux_gnueabi.rs | 4 +- .../src/spec/targets/armebv7r_none_eabi.rs | 4 +- .../src/spec/targets/armebv7r_none_eabihf.rs | 4 +- .../src/spec/targets/armv4t_none_eabi.rs | 4 +- .../targets/armv4t_unknown_linux_gnueabi.rs | 4 +- .../src/spec/targets/armv5te_none_eabi.rs | 4 +- .../targets/armv5te_unknown_linux_gnueabi.rs | 4 +- .../targets/armv5te_unknown_linux_musleabi.rs | 4 +- .../armv5te_unknown_linux_uclibceabi.rs | 4 +- .../src/spec/targets/armv6_unknown_freebsd.rs | 4 +- .../targets/armv6_unknown_netbsd_eabihf.rs | 4 +- .../src/spec/targets/armv6k_nintendo_3ds.rs | 4 +- .../spec/targets/armv7_linux_androideabi.rs | 5 +- .../src/spec/targets/armv7_rtems_eabihf.rs | 4 +- .../targets/armv7_sony_vita_newlibeabihf.rs | 4 +- .../src/spec/targets/armv7_unknown_freebsd.rs | 4 +- .../targets/armv7_unknown_linux_gnueabi.rs | 4 +- .../targets/armv7_unknown_linux_gnueabihf.rs | 4 +- .../targets/armv7_unknown_linux_musleabi.rs | 4 +- .../targets/armv7_unknown_linux_musleabihf.rs | 4 +- .../spec/targets/armv7_unknown_linux_ohos.rs | 4 +- .../targets/armv7_unknown_linux_uclibceabi.rs | 4 +- .../armv7_unknown_linux_uclibceabihf.rs | 4 +- .../targets/armv7_unknown_netbsd_eabihf.rs | 4 +- .../src/spec/targets/armv7_unknown_trusty.rs | 4 +- .../spec/targets/armv7_wrs_vxworks_eabihf.rs | 4 +- .../targets/armv7a_kmc_solid_asp3_eabi.rs | 4 +- .../targets/armv7a_kmc_solid_asp3_eabihf.rs | 4 +- .../src/spec/targets/armv7a_none_eabi.rs | 4 +- .../src/spec/targets/armv7a_none_eabihf.rs | 4 +- .../src/spec/targets/armv7a_nuttx_eabi.rs | 4 +- .../src/spec/targets/armv7a_nuttx_eabihf.rs | 4 +- .../src/spec/targets/armv7a_vex_v5.rs | 4 +- .../src/spec/targets/armv7r_none_eabi.rs | 4 +- .../src/spec/targets/armv7r_none_eabihf.rs | 4 +- .../src/spec/targets/armv8r_none_eabihf.rs | 4 +- .../rustc_target/src/spec/targets/avr_none.rs | 4 +- .../src/spec/targets/bpfeb_unknown_none.rs | 4 +- .../src/spec/targets/bpfel_unknown_none.rs | 4 +- .../targets/csky_unknown_linux_gnuabiv2.rs | 4 +- .../targets/csky_unknown_linux_gnuabiv2hf.rs | 4 +- .../targets/hexagon_unknown_linux_musl.rs | 4 +- .../spec/targets/hexagon_unknown_none_elf.rs | 4 +- .../src/spec/targets/i586_unknown_netbsd.rs | 4 +- .../src/spec/targets/i586_unknown_redox.rs | 4 +- .../src/spec/targets/i686_linux_android.rs | 4 +- .../src/spec/targets/i686_pc_nto_qnx700.rs | 4 +- .../src/spec/targets/i686_pc_windows_gnu.rs | 4 +- .../spec/targets/i686_pc_windows_gnullvm.rs | 6 +- .../src/spec/targets/i686_pc_windows_msvc.rs | 4 +- .../src/spec/targets/i686_unknown_freebsd.rs | 6 +- .../src/spec/targets/i686_unknown_haiku.rs | 6 +- .../src/spec/targets/i686_unknown_helenos.rs | 4 +- .../src/spec/targets/i686_unknown_hurd_gnu.rs | 4 +- .../spec/targets/i686_unknown_linux_gnu.rs | 5 +- .../spec/targets/i686_unknown_linux_musl.rs | 5 +- .../src/spec/targets/i686_unknown_netbsd.rs | 5 +- .../src/spec/targets/i686_unknown_openbsd.rs | 6 +- .../src/spec/targets/i686_unknown_uefi.rs | 4 +- .../src/spec/targets/i686_uwp_windows_gnu.rs | 6 +- .../src/spec/targets/i686_uwp_windows_msvc.rs | 4 +- .../src/spec/targets/i686_win7_windows_gnu.rs | 6 +- .../spec/targets/i686_win7_windows_msvc.rs | 4 +- .../src/spec/targets/i686_wrs_vxworks.rs | 6 +- .../spec/targets/loongarch32_unknown_none.rs | 4 +- .../loongarch32_unknown_none_softfloat.rs | 4 +- .../targets/loongarch64_unknown_linux_gnu.rs | 4 +- .../targets/loongarch64_unknown_linux_musl.rs | 4 +- .../targets/loongarch64_unknown_linux_ohos.rs | 4 +- .../spec/targets/loongarch64_unknown_none.rs | 4 +- .../loongarch64_unknown_none_softfloat.rs | 4 +- .../spec/targets/m68k_unknown_linux_gnu.rs | 4 +- .../src/spec/targets/m68k_unknown_none_elf.rs | 6 +- .../spec/targets/mips64_openwrt_linux_musl.rs | 4 +- .../targets/mips64_unknown_linux_gnuabi64.rs | 4 +- .../targets/mips64_unknown_linux_muslabi64.rs | 4 +- .../mips64el_unknown_linux_gnuabi64.rs | 4 +- .../mips64el_unknown_linux_muslabi64.rs | 4 +- .../src/spec/targets/mips_mti_none_elf.rs | 4 +- .../spec/targets/mips_unknown_linux_gnu.rs | 4 +- .../spec/targets/mips_unknown_linux_musl.rs | 4 +- .../spec/targets/mips_unknown_linux_uclibc.rs | 4 +- .../src/spec/targets/mipsel_mti_none_elf.rs | 4 +- .../src/spec/targets/mipsel_sony_psp.rs | 6 +- .../src/spec/targets/mipsel_sony_psx.rs | 5 +- .../spec/targets/mipsel_unknown_linux_gnu.rs | 4 +- .../spec/targets/mipsel_unknown_linux_musl.rs | 4 +- .../targets/mipsel_unknown_linux_uclibc.rs | 4 +- .../src/spec/targets/mipsel_unknown_netbsd.rs | 4 +- .../src/spec/targets/mipsel_unknown_none.rs | 4 +- .../targets/mipsisa32r6_unknown_linux_gnu.rs | 4 +- .../mipsisa32r6el_unknown_linux_gnu.rs | 4 +- .../mipsisa64r6_unknown_linux_gnuabi64.rs | 4 +- .../mipsisa64r6el_unknown_linux_gnuabi64.rs | 4 +- .../src/spec/targets/msp430_none_elf.rs | 4 +- .../src/spec/targets/nvptx64_nvidia_cuda.rs | 6 +- .../src/spec/targets/powerpc64_ibm_aix.rs | 4 +- .../spec/targets/powerpc64_unknown_freebsd.rs | 4 +- .../targets/powerpc64_unknown_linux_gnu.rs | 4 +- .../targets/powerpc64_unknown_linux_musl.rs | 4 +- .../spec/targets/powerpc64_unknown_openbsd.rs | 4 +- .../src/spec/targets/powerpc64_wrs_vxworks.rs | 4 +- .../targets/powerpc64le_unknown_freebsd.rs | 4 +- .../targets/powerpc64le_unknown_linux_gnu.rs | 4 +- .../targets/powerpc64le_unknown_linux_musl.rs | 4 +- .../spec/targets/powerpc_unknown_freebsd.rs | 4 +- .../spec/targets/powerpc_unknown_helenos.rs | 4 +- .../spec/targets/powerpc_unknown_linux_gnu.rs | 4 +- .../targets/powerpc_unknown_linux_gnuspe.rs | 4 +- .../targets/powerpc_unknown_linux_musl.rs | 4 +- .../targets/powerpc_unknown_linux_muslspe.rs | 4 +- .../spec/targets/powerpc_unknown_netbsd.rs | 4 +- .../spec/targets/powerpc_unknown_openbsd.rs | 4 +- .../src/spec/targets/powerpc_wrs_vxworks.rs | 4 +- .../spec/targets/powerpc_wrs_vxworks_spe.rs | 4 +- .../src/spec/targets/riscv32_wrs_vxworks.rs | 4 +- .../spec/targets/riscv32e_unknown_none_elf.rs | 4 +- .../targets/riscv32em_unknown_none_elf.rs | 4 +- .../targets/riscv32emc_unknown_none_elf.rs | 4 +- .../targets/riscv32gc_unknown_linux_gnu.rs | 4 +- .../targets/riscv32gc_unknown_linux_musl.rs | 4 +- .../spec/targets/riscv32i_unknown_none_elf.rs | 4 +- .../spec/targets/riscv32im_risc0_zkvm_elf.rs | 4 +- .../targets/riscv32im_unknown_none_elf.rs | 4 +- .../targets/riscv32ima_unknown_none_elf.rs | 4 +- .../spec/targets/riscv32imac_esp_espidf.rs | 4 +- .../targets/riscv32imac_unknown_none_elf.rs | 4 +- .../targets/riscv32imac_unknown_nuttx_elf.rs | 5 +- .../targets/riscv32imac_unknown_xous_elf.rs | 4 +- .../spec/targets/riscv32imafc_esp_espidf.rs | 4 +- .../targets/riscv32imafc_unknown_none_elf.rs | 4 +- .../targets/riscv32imafc_unknown_nuttx_elf.rs | 5 +- .../src/spec/targets/riscv32imc_esp_espidf.rs | 4 +- .../targets/riscv32imc_unknown_none_elf.rs | 4 +- .../targets/riscv32imc_unknown_nuttx_elf.rs | 5 +- .../src/spec/targets/riscv64_linux_android.rs | 4 +- .../src/spec/targets/riscv64_wrs_vxworks.rs | 4 +- .../targets/riscv64a23_unknown_linux_gnu.rs | 4 +- .../spec/targets/riscv64gc_unknown_freebsd.rs | 4 +- .../spec/targets/riscv64gc_unknown_fuchsia.rs | 4 +- .../spec/targets/riscv64gc_unknown_hermit.rs | 6 +- .../targets/riscv64gc_unknown_linux_gnu.rs | 4 +- .../targets/riscv64gc_unknown_linux_musl.rs | 4 +- .../riscv64gc_unknown_managarm_mlibc.rs | 4 +- .../spec/targets/riscv64gc_unknown_netbsd.rs | 4 +- .../targets/riscv64gc_unknown_none_elf.rs | 4 +- .../targets/riscv64gc_unknown_nuttx_elf.rs | 4 +- .../spec/targets/riscv64gc_unknown_openbsd.rs | 4 +- .../spec/targets/riscv64gc_unknown_redox.rs | 4 +- .../targets/riscv64imac_unknown_none_elf.rs | 4 +- .../targets/riscv64imac_unknown_nuttx_elf.rs | 4 +- .../spec/targets/s390x_unknown_linux_gnu.rs | 4 +- .../spec/targets/s390x_unknown_linux_musl.rs | 4 +- .../spec/targets/sparc64_unknown_helenos.rs | 4 +- .../spec/targets/sparc64_unknown_linux_gnu.rs | 4 +- .../spec/targets/sparc64_unknown_netbsd.rs | 4 +- .../spec/targets/sparc64_unknown_openbsd.rs | 4 +- .../spec/targets/sparc_unknown_linux_gnu.rs | 4 +- .../spec/targets/sparc_unknown_none_elf.rs | 4 +- .../src/spec/targets/sparcv9_sun_solaris.rs | 4 +- .../src/spec/targets/thumbv4t_none_eabi.rs | 6 +- .../src/spec/targets/thumbv5te_none_eabi.rs | 4 +- .../src/spec/targets/thumbv6m_none_eabi.rs | 4 +- .../src/spec/targets/thumbv6m_nuttx_eabi.rs | 4 +- .../src/spec/targets/thumbv7a_nuttx_eabi.rs | 4 +- .../src/spec/targets/thumbv7a_nuttx_eabihf.rs | 4 +- .../spec/targets/thumbv7a_pc_windows_msvc.rs | 4 +- .../spec/targets/thumbv7a_uwp_windows_msvc.rs | 4 +- .../src/spec/targets/thumbv7em_none_eabi.rs | 4 +- .../src/spec/targets/thumbv7em_none_eabihf.rs | 4 +- .../src/spec/targets/thumbv7em_nuttx_eabi.rs | 4 +- .../spec/targets/thumbv7em_nuttx_eabihf.rs | 4 +- .../src/spec/targets/thumbv7m_none_eabi.rs | 4 +- .../src/spec/targets/thumbv7m_nuttx_eabi.rs | 4 +- .../targets/thumbv7neon_linux_androideabi.rs | 6 +- .../thumbv7neon_unknown_linux_gnueabihf.rs | 4 +- .../thumbv7neon_unknown_linux_musleabihf.rs | 4 +- .../spec/targets/thumbv8m_base_none_eabi.rs | 4 +- .../spec/targets/thumbv8m_base_nuttx_eabi.rs | 4 +- .../spec/targets/thumbv8m_main_none_eabi.rs | 4 +- .../spec/targets/thumbv8m_main_none_eabihf.rs | 4 +- .../spec/targets/thumbv8m_main_nuttx_eabi.rs | 4 +- .../targets/thumbv8m_main_nuttx_eabihf.rs | 4 +- .../spec/targets/wasm32_unknown_emscripten.rs | 6 +- .../spec/targets/wasm32_unknown_unknown.rs | 4 +- .../spec/targets/wasm32_wali_linux_musl.rs | 4 +- .../src/spec/targets/wasm32_wasip1.rs | 4 +- .../src/spec/targets/wasm32_wasip1_threads.rs | 4 +- .../src/spec/targets/wasm32_wasip2.rs | 4 +- .../src/spec/targets/wasm32v1_none.rs | 4 +- .../spec/targets/wasm64_unknown_unknown.rs | 4 +- .../targets/x86_64_fortanix_unknown_sgx.rs | 4 +- .../src/spec/targets/x86_64_linux_android.rs | 6 +- .../src/spec/targets/x86_64_lynx_lynxos178.rs | 4 +- .../src/spec/targets/x86_64_pc_cygwin.rs | 4 +- .../src/spec/targets/x86_64_pc_solaris.rs | 6 +- .../src/spec/targets/x86_64_pc_windows_gnu.rs | 4 +- .../spec/targets/x86_64_pc_windows_gnullvm.rs | 4 +- .../spec/targets/x86_64_pc_windows_msvc.rs | 4 +- .../targets/x86_64_unikraft_linux_musl.rs | 4 +- .../spec/targets/x86_64_unknown_dragonfly.rs | 4 +- .../spec/targets/x86_64_unknown_freebsd.rs | 4 +- .../spec/targets/x86_64_unknown_fuchsia.rs | 4 +- .../src/spec/targets/x86_64_unknown_haiku.rs | 4 +- .../spec/targets/x86_64_unknown_helenos.rs | 4 +- .../src/spec/targets/x86_64_unknown_hermit.rs | 4 +- .../spec/targets/x86_64_unknown_hurd_gnu.rs | 4 +- .../spec/targets/x86_64_unknown_illumos.rs | 4 +- .../targets/x86_64_unknown_l4re_uclibc.rs | 4 +- .../spec/targets/x86_64_unknown_linux_gnu.rs | 4 +- .../targets/x86_64_unknown_linux_gnux32.rs | 4 +- .../spec/targets/x86_64_unknown_linux_musl.rs | 4 +- .../spec/targets/x86_64_unknown_linux_none.rs | 4 +- .../spec/targets/x86_64_unknown_linux_ohos.rs | 4 +- .../targets/x86_64_unknown_managarm_mlibc.rs | 4 +- .../src/spec/targets/x86_64_unknown_motor.rs | 4 +- .../src/spec/targets/x86_64_unknown_netbsd.rs | 6 +- .../src/spec/targets/x86_64_unknown_none.rs | 4 +- .../spec/targets/x86_64_unknown_openbsd.rs | 4 +- .../src/spec/targets/x86_64_unknown_redox.rs | 4 +- .../src/spec/targets/x86_64_unknown_trusty.rs | 6 +- .../src/spec/targets/x86_64_unknown_uefi.rs | 4 +- .../spec/targets/x86_64_uwp_windows_gnu.rs | 4 +- .../spec/targets/x86_64_uwp_windows_msvc.rs | 4 +- .../spec/targets/x86_64_win7_windows_gnu.rs | 4 +- .../spec/targets/x86_64_win7_windows_msvc.rs | 4 +- .../src/spec/targets/x86_64_wrs_vxworks.rs | 4 +- .../src/spec/targets/xtensa_esp32_espidf.rs | 4 +- .../src/spec/targets/xtensa_esp32_none_elf.rs | 4 +- .../src/spec/targets/xtensa_esp32s2_espidf.rs | 4 +- .../spec/targets/xtensa_esp32s2_none_elf.rs | 4 +- .../src/spec/targets/xtensa_esp32s3_espidf.rs | 4 +- .../spec/targets/xtensa_esp32s3_none_elf.rs | 4 +- compiler/rustc_target/src/target_features.rs | 98 ++++++---- src/tools/miri/src/machine.rs | 7 +- src/tools/miri/src/shims/alloc.rs | 43 +++- src/tools/miri/src/shims/foreign_items.rs | 13 +- .../miri/src/shims/windows/foreign_items.rs | 3 +- src/tools/miri/src/shims/x86/bmi.rs | 3 +- src/tools/miri/src/shims/x86/mod.rs | 7 +- src/tools/miri/src/shims/x86/sse42.rs | 3 +- 322 files changed, 1209 insertions(+), 1030 deletions(-) diff --git a/compiler/rustc_attr_parsing/src/attributes/link_attrs.rs b/compiler/rustc_attr_parsing/src/attributes/link_attrs.rs index 065ed8959fc75..5a4a4e7599101 100644 --- a/compiler/rustc_attr_parsing/src/attributes/link_attrs.rs +++ b/compiler/rustc_attr_parsing/src/attributes/link_attrs.rs @@ -4,7 +4,7 @@ use rustc_hir::attrs::*; use rustc_session::Session; use rustc_session::parse::feature_err; use rustc_span::kw; -use rustc_target::spec::BinaryFormat; +use rustc_target::spec::{Arch, BinaryFormat}; use super::prelude::*; use super::util::parse_single_integer; @@ -438,7 +438,7 @@ impl LinkParser { cx.expected_name_value(item.span(), Some(sym::import_name_type)); return true; }; - if cx.sess().target.arch != "x86" { + if cx.sess().target.arch != Arch::X86 { cx.emit_err(ImportNameTypeX86 { span: item.span() }); return true; } diff --git a/compiler/rustc_codegen_cranelift/src/abi/mod.rs b/compiler/rustc_codegen_cranelift/src/abi/mod.rs index 9a9a1f4a2c0f8..6ea26b02c2619 100644 --- a/compiler/rustc_codegen_cranelift/src/abi/mod.rs +++ b/compiler/rustc_codegen_cranelift/src/abi/mod.rs @@ -20,6 +20,7 @@ use rustc_middle::ty::print::with_no_trimmed_paths; use rustc_session::Session; use rustc_span::source_map::Spanned; use rustc_target::callconv::{FnAbi, PassMode}; +use rustc_target::spec::Arch; use smallvec::SmallVec; use self::pass_mode::*; @@ -155,7 +156,7 @@ impl<'tcx> FunctionCx<'_, '_, 'tcx> { let ret = self.lib_call_unadjusted(name, params, returns, &args)[0]; Cow::Owned(vec![codegen_bitcast(self, types::I128, ret)]) - } else if ret_single_i128 && self.tcx.sess.target.arch == "s390x" { + } else if ret_single_i128 && self.tcx.sess.target.arch == Arch::S390x { // Return i128 using a return area pointer on s390x. let mut params = params; let mut args = args.to_vec(); @@ -641,7 +642,7 @@ pub(crate) fn codegen_terminator_call<'tcx>( .flat_map(|arg_abi| arg_abi.get_abi_param(fx.tcx).into_iter()), ); - if fx.tcx.sess.target.is_like_darwin && fx.tcx.sess.target.arch == "aarch64" { + if fx.tcx.sess.target.is_like_darwin && fx.tcx.sess.target.arch == Arch::AArch64 { // Add any padding arguments needed for Apple AArch64. // There's no need to pad the argument list unless variadic arguments are actually being // passed. @@ -787,25 +788,25 @@ pub(crate) fn codegen_drop<'tcx>( pub(crate) fn lib_call_arg_param(tcx: TyCtxt<'_>, ty: Type, is_signed: bool) -> AbiParam { let param = AbiParam::new(ty); if ty.is_int() && u64::from(ty.bits()) < tcx.data_layout.pointer_size().bits() { - match (&*tcx.sess.target.arch, &*tcx.sess.target.vendor) { - ("x86_64", _) | ("aarch64", "apple") => match (ty, is_signed) { + match (tcx.sess.target.arch, tcx.sess.target.vendor.as_ref()) { + (Arch::X86_64, _) | (Arch::AArch64, "apple") => match (ty, is_signed) { (types::I8 | types::I16, true) => param.sext(), (types::I8 | types::I16, false) => param.uext(), _ => param, }, - ("aarch64", _) => param, - ("riscv64", _) => match (ty, is_signed) { + (Arch::AArch64, _) => param, + (Arch::RiscV64, _) => match (ty, is_signed) { (types::I32, _) | (_, true) => param.sext(), _ => param.uext(), }, - ("s390x", _) => { + (Arch::S390x, _) => { if is_signed { param.sext() } else { param.uext() } } - _ => unimplemented!("{:?}", tcx.sess.target.arch), + (arch, _) => unimplemented!("{arch:?}"), } } else { param diff --git a/compiler/rustc_codegen_cranelift/src/codegen_f16_f128.rs b/compiler/rustc_codegen_cranelift/src/codegen_f16_f128.rs index 1e202be1f1855..c0f6d9d853db2 100644 --- a/compiler/rustc_codegen_cranelift/src/codegen_f16_f128.rs +++ b/compiler/rustc_codegen_cranelift/src/codegen_f16_f128.rs @@ -1,8 +1,10 @@ +use rustc_target::spec::Arch; + use crate::prelude::*; pub(crate) fn f16_to_f32(fx: &mut FunctionCx<'_, '_, '_>, value: Value) -> Value { let (value, arg_ty) = - if fx.tcx.sess.target.vendor == "apple" && fx.tcx.sess.target.arch == "x86_64" { + if fx.tcx.sess.target.vendor == "apple" && fx.tcx.sess.target.arch == Arch::X86_64 { ( fx.bcx.ins().bitcast(types::I16, MemFlags::new(), value), lib_call_arg_param(fx.tcx, types::I16, false), @@ -19,7 +21,8 @@ fn f16_to_f64(fx: &mut FunctionCx<'_, '_, '_>, value: Value) -> Value { } pub(crate) fn f32_to_f16(fx: &mut FunctionCx<'_, '_, '_>, value: Value) -> Value { - let ret_ty = if fx.tcx.sess.target.vendor == "apple" && fx.tcx.sess.target.arch == "x86_64" { + let ret_ty = if fx.tcx.sess.target.vendor == "apple" && fx.tcx.sess.target.arch == Arch::X86_64 + { types::I16 } else { types::F16 @@ -34,7 +37,8 @@ pub(crate) fn f32_to_f16(fx: &mut FunctionCx<'_, '_, '_>, value: Value) -> Value } fn f64_to_f16(fx: &mut FunctionCx<'_, '_, '_>, value: Value) -> Value { - let ret_ty = if fx.tcx.sess.target.vendor == "apple" && fx.tcx.sess.target.arch == "x86_64" { + let ret_ty = if fx.tcx.sess.target.vendor == "apple" && fx.tcx.sess.target.arch == Arch::X86_64 + { types::I16 } else { types::F16 diff --git a/compiler/rustc_codegen_cranelift/src/common.rs b/compiler/rustc_codegen_cranelift/src/common.rs index 81b1814605a12..de3d2f31af103 100644 --- a/compiler/rustc_codegen_cranelift/src/common.rs +++ b/compiler/rustc_codegen_cranelift/src/common.rs @@ -8,7 +8,7 @@ use rustc_middle::ty::layout::{ }; use rustc_span::source_map::Spanned; use rustc_target::callconv::FnAbi; -use rustc_target::spec::{HasTargetSpec, Target}; +use rustc_target::spec::{Arch, HasTargetSpec, Target}; use crate::constant::ConstantCx; use crate::debuginfo::FunctionDebugContext; @@ -373,7 +373,7 @@ impl<'tcx> FunctionCx<'_, '_, 'tcx> { "size must be a multiple of alignment (size={size}, align={align})" ); - let abi_align = if self.tcx.sess.target.arch == "s390x" { 8 } else { 16 }; + let abi_align = if self.tcx.sess.target.arch == Arch::S390x { 8 } else { 16 }; if align <= abi_align { let stack_slot = self.bcx.create_sized_stack_slot(StackSlotData { kind: StackSlotKind::ExplicitSlot, diff --git a/compiler/rustc_codegen_cranelift/src/lib.rs b/compiler/rustc_codegen_cranelift/src/lib.rs index 5d48d0c94c581..5c23cd02e0d3a 100644 --- a/compiler/rustc_codegen_cranelift/src/lib.rs +++ b/compiler/rustc_codegen_cranelift/src/lib.rs @@ -50,6 +50,7 @@ use rustc_middle::dep_graph::{WorkProduct, WorkProductId}; use rustc_session::Session; use rustc_session::config::OutputFilenames; use rustc_span::{Symbol, sym}; +use rustc_target::spec::Arch; pub use crate::config::*; use crate::prelude::*; @@ -186,20 +187,20 @@ impl CodegenBackend for CraneliftCodegenBackend { fn target_config(&self, sess: &Session) -> TargetConfig { // FIXME return the actually used target features. this is necessary for #[cfg(target_feature)] - let target_features = if sess.target.arch == "x86_64" && sess.target.os != "none" { - // x86_64 mandates SSE2 support and rustc requires the x87 feature to be enabled - vec![sym::fxsr, sym::sse, sym::sse2, Symbol::intern("x87")] - } else if sess.target.arch == "aarch64" { - match &*sess.target.os { + let target_features = match sess.target.arch { + Arch::X86_64 if sess.target.os != "none" => { + // x86_64 mandates SSE2 support and rustc requires the x87 feature to be enabled + vec![sym::fxsr, sym::sse, sym::sse2, Symbol::intern("x87")] + } + Arch::AArch64 => match &*sess.target.os { "none" => vec![], // On macOS the aes, sha2 and sha3 features are enabled by default and ring // fails to compile on macOS when they are not present. "macos" => vec![sym::neon, sym::aes, sym::sha2, sym::sha3], // AArch64 mandates Neon support _ => vec![sym::neon], - } - } else { - vec![] + }, + _ => vec![], }; // FIXME do `unstable_target_features` properly let unstable_target_features = target_features.clone(); @@ -208,14 +209,14 @@ impl CodegenBackend for CraneliftCodegenBackend { // Windows, whereas LLVM 21+ and Cranelift pass it indirectly. This means that `f128` won't // work when linking against a LLVM-built sysroot. let has_reliable_f128 = !sess.target.is_like_windows; - let has_reliable_f16 = match &*sess.target.arch { + let has_reliable_f16 = match sess.target.arch { // FIXME(f16_f128): LLVM 20 does not support `f16` on s390x, meaning the required // builtins are not available in `compiler-builtins`. - "s390x" => false, + Arch::S390x => false, // FIXME(f16_f128): `rustc_codegen_llvm` currently disables support on Windows GNU // targets due to GCC using a different ABI than LLVM. Therefore `f16` won't be // available when using a LLVM-built sysroot. - "x86_64" + Arch::X86_64 if sess.target.os == "windows" && sess.target.env == "gnu" && sess.target.abi != "llvm" => diff --git a/compiler/rustc_codegen_gcc/src/abi.rs b/compiler/rustc_codegen_gcc/src/abi.rs index 0b359f1c5c81b..b7d0e19ee2725 100644 --- a/compiler/rustc_codegen_gcc/src/abi.rs +++ b/compiler/rustc_codegen_gcc/src/abi.rs @@ -12,6 +12,8 @@ use rustc_middle::ty::layout::LayoutOf; #[cfg(feature = "master")] use rustc_session::config; use rustc_target::callconv::{ArgAttributes, CastTarget, FnAbi, PassMode}; +#[cfg(feature = "master")] +use rustc_target::spec::Arch; use crate::builder::Builder; use crate::context::CodegenCx; @@ -233,12 +235,12 @@ impl<'gcc, 'tcx> FnAbiGccExt<'gcc, 'tcx> for FnAbi<'tcx, Ty<'tcx>> { #[cfg(feature = "master")] fn gcc_cconv(&self, cx: &CodegenCx<'gcc, 'tcx>) -> Option> { - conv_to_fn_attribute(self.conv, &cx.tcx.sess.target.arch) + conv_to_fn_attribute(self.conv, cx.tcx.sess.target.arch) } } #[cfg(feature = "master")] -pub fn conv_to_fn_attribute<'gcc>(conv: CanonAbi, arch: &str) -> Option> { +pub fn conv_to_fn_attribute<'gcc>(conv: CanonAbi, arch: Arch) -> Option> { let attribute = match conv { CanonAbi::C | CanonAbi::Rust => return None, CanonAbi::RustCold => FnAttribute::Cold, @@ -251,15 +253,11 @@ pub fn conv_to_fn_attribute<'gcc>(conv: CanonAbi, arch: &str) -> Option FnAttribute::ArmCmseNonsecureEntry, ArmCall::Aapcs => FnAttribute::ArmPcs("aapcs"), }, - CanonAbi::GpuKernel => { - if arch == "amdgpu" { - FnAttribute::GcnAmdGpuHsaKernel - } else if arch == "nvptx64" { - FnAttribute::NvptxKernel - } else { - panic!("Architecture {} does not support GpuKernel calling convention", arch); - } - } + CanonAbi::GpuKernel => match arch { + Arch::AmdGpu => FnAttribute::GcnAmdGpuHsaKernel, + Arch::Nvptx64 => FnAttribute::NvptxKernel, + arch => panic!("Arch {arch} does not support GpuKernel calling convention"), + }, // TODO(antoyo): check if those AVR attributes are mapped correctly. CanonAbi::Interrupt(interrupt_kind) => match interrupt_kind { InterruptKind::Avr => FnAttribute::AvrSignal, diff --git a/compiler/rustc_codegen_gcc/src/attributes.rs b/compiler/rustc_codegen_gcc/src/attributes.rs index 04b43bb8bb7c4..5df1dc41b01dd 100644 --- a/compiler/rustc_codegen_gcc/src/attributes.rs +++ b/compiler/rustc_codegen_gcc/src/attributes.rs @@ -9,6 +9,8 @@ use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrFlags; #[cfg(feature = "master")] use rustc_middle::mir::TerminatorKind; use rustc_middle::ty; +#[cfg(feature = "master")] +use rustc_target::spec::Arch; use crate::context::CodegenCx; use crate::gcc_util::to_gcc_features; @@ -70,7 +72,7 @@ fn inline_attr<'gcc, 'tcx>( InlineAttr::Hint => Some(FnAttribute::Inline), InlineAttr::Force { .. } => Some(FnAttribute::AlwaysInline), InlineAttr::Never => { - if cx.sess().target.arch != "amdgpu" { + if cx.sess().target.arch != Arch::AmdGpu { Some(FnAttribute::NoInline) } else { None @@ -153,8 +155,8 @@ pub fn from_fn_attrs<'gcc, 'tcx>( .join(","); if !target_features.is_empty() { #[cfg(feature = "master")] - match cx.sess().target.arch.as_ref() { - "x86" | "x86_64" | "powerpc" => { + match cx.sess().target.arch { + Arch::X86 | Arch::X86_64 | Arch::PowerPC => { func.add_attribute(FnAttribute::Target(&target_features)) } // The target attribute is not supported on other targets in GCC. diff --git a/compiler/rustc_codegen_gcc/src/base.rs b/compiler/rustc_codegen_gcc/src/base.rs index e8672f49580b6..0a0f0ed37f0b5 100644 --- a/compiler/rustc_codegen_gcc/src/base.rs +++ b/compiler/rustc_codegen_gcc/src/base.rs @@ -15,9 +15,9 @@ use rustc_middle::mir::mono::Visibility; use rustc_middle::ty::TyCtxt; use rustc_session::config::DebugInfo; use rustc_span::Symbol; -use rustc_target::spec::RelocModel; #[cfg(feature = "master")] use rustc_target::spec::SymbolVisibility; +use rustc_target::spec::{Arch, RelocModel}; use crate::builder::Builder; use crate::context::CodegenCx; @@ -116,7 +116,7 @@ pub fn compile_codegen_unit( .map(|string| &string[1..]) .collect(); - if !disabled_features.contains("avx") && tcx.sess.target.arch == "x86_64" { + if !disabled_features.contains("avx") && tcx.sess.target.arch == Arch::X86_64 { // NOTE: we always enable AVX because the equivalent of llvm.x86.sse2.cmp.pd in GCC for // SSE2 is multiple builtins, so we use the AVX __builtin_ia32_cmppd instead. // FIXME(antoyo): use the proper builtins for llvm.x86.sse2.cmp.pd and similar. diff --git a/compiler/rustc_codegen_gcc/src/context.rs b/compiler/rustc_codegen_gcc/src/context.rs index c9ae96777de44..6084b4fc07fac 100644 --- a/compiler/rustc_codegen_gcc/src/context.rs +++ b/compiler/rustc_codegen_gcc/src/context.rs @@ -487,7 +487,7 @@ impl<'gcc, 'tcx> MiscCodegenMethods<'tcx> for CodegenCx<'gcc, 'tcx> { let entry_name = self.sess().target.entry_name.as_ref(); if !self.functions.borrow().contains_key(entry_name) { #[cfg(feature = "master")] - let conv = conv_to_fn_attribute(self.sess().target.entry_abi, &self.sess().target.arch); + let conv = conv_to_fn_attribute(self.sess().target.entry_abi, self.sess().target.arch); #[cfg(not(feature = "master"))] let conv = None; Some(self.declare_entry_fn(entry_name, fn_type, conv)) diff --git a/compiler/rustc_codegen_gcc/src/gcc_util.rs b/compiler/rustc_codegen_gcc/src/gcc_util.rs index 702704ddf1369..83d54472e5ded 100644 --- a/compiler/rustc_codegen_gcc/src/gcc_util.rs +++ b/compiler/rustc_codegen_gcc/src/gcc_util.rs @@ -3,6 +3,7 @@ use gccjit::Context; use rustc_codegen_ssa::target_features; use rustc_data_structures::smallvec::{SmallVec, smallvec}; use rustc_session::Session; +use rustc_target::spec::Arch; fn gcc_features_by_flags(sess: &Session, features: &mut Vec) { target_features::retpoline_features_by_flags(sess, features); @@ -65,44 +66,47 @@ pub(crate) fn global_gcc_features(sess: &Session, diagnostics: bool) -> Vec(sess: &Session, s: &'a str) -> SmallVec<[&'a str; 2]> { - let arch = if sess.target.arch == "x86_64" { "x86" } else { &*sess.target.arch }; // cSpell:disable - match (arch, s) { + match (sess.target.arch, s) { // FIXME: seems like x87 does not exist? - ("x86", "x87") => smallvec![], - ("x86", "sse4.2") => smallvec!["sse4.2", "crc32"], - ("x86", "pclmulqdq") => smallvec!["pclmul"], - ("x86", "rdrand") => smallvec!["rdrnd"], - ("x86", "bmi1") => smallvec!["bmi"], - ("x86", "cmpxchg16b") => smallvec!["cx16"], - ("x86", "avx512vaes") => smallvec!["vaes"], - ("x86", "avx512gfni") => smallvec!["gfni"], - ("x86", "avx512vpclmulqdq") => smallvec!["vpclmulqdq"], + (Arch::X86 | Arch::X86_64, "x87") => smallvec![], + (Arch::X86 | Arch::X86_64, "sse4.2") => smallvec!["sse4.2", "crc32"], + (Arch::X86 | Arch::X86_64, "pclmulqdq") => smallvec!["pclmul"], + (Arch::X86 | Arch::X86_64, "rdrand") => smallvec!["rdrnd"], + (Arch::X86 | Arch::X86_64, "bmi1") => smallvec!["bmi"], + (Arch::X86 | Arch::X86_64, "cmpxchg16b") => smallvec!["cx16"], + (Arch::X86 | Arch::X86_64, "avx512vaes") => smallvec!["vaes"], + (Arch::X86 | Arch::X86_64, "avx512gfni") => smallvec!["gfni"], + (Arch::X86 | Arch::X86_64, "avx512vpclmulqdq") => smallvec!["vpclmulqdq"], // NOTE: seems like GCC requires 'avx512bw' for 'avx512vbmi2'. - ("x86", "avx512vbmi2") => smallvec!["avx512vbmi2", "avx512bw"], + (Arch::X86 | Arch::X86_64, "avx512vbmi2") => { + smallvec!["avx512vbmi2", "avx512bw"] + } // NOTE: seems like GCC requires 'avx512bw' for 'avx512bitalg'. - ("x86", "avx512bitalg") => smallvec!["avx512bitalg", "avx512bw"], - ("aarch64", "rcpc2") => smallvec!["rcpc-immo"], - ("aarch64", "dpb") => smallvec!["ccpp"], - ("aarch64", "dpb2") => smallvec!["ccdp"], - ("aarch64", "frintts") => smallvec!["fptoint"], - ("aarch64", "fcma") => smallvec!["complxnum"], - ("aarch64", "pmuv3") => smallvec!["perfmon"], - ("aarch64", "paca") => smallvec!["pauth"], - ("aarch64", "pacg") => smallvec!["pauth"], + (Arch::X86 | Arch::X86_64, "avx512bitalg") => { + smallvec!["avx512bitalg", "avx512bw"] + } + (Arch::AArch64, "rcpc2") => smallvec!["rcpc-immo"], + (Arch::AArch64, "dpb") => smallvec!["ccpp"], + (Arch::AArch64, "dpb2") => smallvec!["ccdp"], + (Arch::AArch64, "frintts") => smallvec!["fptoint"], + (Arch::AArch64, "fcma") => smallvec!["complxnum"], + (Arch::AArch64, "pmuv3") => smallvec!["perfmon"], + (Arch::AArch64, "paca") => smallvec!["pauth"], + (Arch::AArch64, "pacg") => smallvec!["pauth"], // Rust ties fp and neon together. In GCC neon implicitly enables fp, // but we manually enable neon when a feature only implicitly enables fp - ("aarch64", "f32mm") => smallvec!["f32mm", "neon"], - ("aarch64", "f64mm") => smallvec!["f64mm", "neon"], - ("aarch64", "fhm") => smallvec!["fp16fml", "neon"], - ("aarch64", "fp16") => smallvec!["fullfp16", "neon"], - ("aarch64", "jsconv") => smallvec!["jsconv", "neon"], - ("aarch64", "sve") => smallvec!["sve", "neon"], - ("aarch64", "sve2") => smallvec!["sve2", "neon"], - ("aarch64", "sve2-aes") => smallvec!["sve2-aes", "neon"], - ("aarch64", "sve2-sm4") => smallvec!["sve2-sm4", "neon"], - ("aarch64", "sve2-sha3") => smallvec!["sve2-sha3", "neon"], - ("aarch64", "sve2-bitperm") => smallvec!["sve2-bitperm", "neon"], + (Arch::AArch64, "f32mm") => smallvec!["f32mm", "neon"], + (Arch::AArch64, "f64mm") => smallvec!["f64mm", "neon"], + (Arch::AArch64, "fhm") => smallvec!["fp16fml", "neon"], + (Arch::AArch64, "fp16") => smallvec!["fullfp16", "neon"], + (Arch::AArch64, "jsconv") => smallvec!["jsconv", "neon"], + (Arch::AArch64, "sve") => smallvec!["sve", "neon"], + (Arch::AArch64, "sve2") => smallvec!["sve2", "neon"], + (Arch::AArch64, "sve2-aes") => smallvec!["sve2-aes", "neon"], + (Arch::AArch64, "sve2-sm4") => smallvec!["sve2-sm4", "neon"], + (Arch::AArch64, "sve2-sha3") => smallvec!["sve2-sha3", "neon"], + (Arch::AArch64, "sve2-bitperm") => smallvec!["sve2-bitperm", "neon"], (_, s) => smallvec![s], } // cSpell:enable diff --git a/compiler/rustc_codegen_gcc/src/lib.rs b/compiler/rustc_codegen_gcc/src/lib.rs index 71500ded02038..9f5b03c02a092 100644 --- a/compiler/rustc_codegen_gcc/src/lib.rs +++ b/compiler/rustc_codegen_gcc/src/lib.rs @@ -103,7 +103,7 @@ use rustc_middle::util::Providers; use rustc_session::Session; use rustc_session::config::{OptLevel, OutputFilenames}; use rustc_span::Symbol; -use rustc_target::spec::RelocModel; +use rustc_target::spec::{Arch, RelocModel}; use tempfile::TempDir; use crate::back::lto::ModuleBuffer; @@ -249,7 +249,7 @@ impl CodegenBackend for GccCodegenBackend { fn new_context<'gcc, 'tcx>(tcx: TyCtxt<'tcx>) -> Context<'gcc> { let context = Context::default(); - if tcx.sess.target.arch == "x86" || tcx.sess.target.arch == "x86_64" { + if matches!(tcx.sess.target.arch, Arch::X86 | Arch::X86_64) { context.add_command_line_option("-masm=intel"); } #[cfg(feature = "master")] diff --git a/compiler/rustc_codegen_llvm/src/abi.rs b/compiler/rustc_codegen_llvm/src/abi.rs index 3793a1470aada..b045af3161dc2 100644 --- a/compiler/rustc_codegen_llvm/src/abi.rs +++ b/compiler/rustc_codegen_llvm/src/abi.rs @@ -16,7 +16,7 @@ use rustc_session::{Session, config}; use rustc_target::callconv::{ ArgAbi, ArgAttribute, ArgAttributes, ArgExtension, CastTarget, FnAbi, PassMode, }; -use rustc_target::spec::SanitizerSet; +use rustc_target::spec::{Arch, SanitizerSet}; use smallvec::SmallVec; use crate::attributes::{self, llfn_attrs_from_instance}; @@ -698,16 +698,11 @@ pub(crate) fn to_llvm_calling_convention(sess: &Session, abi: CanonAbi) -> llvm: // possible to declare an `extern "custom"` block, so the backend still needs a calling // convention for declaring foreign functions. CanonAbi::Custom => llvm::CCallConv, - CanonAbi::GpuKernel => { - let arch = sess.target.arch.as_ref(); - if arch == "amdgpu" { - llvm::AmdgpuKernel - } else if arch == "nvptx64" { - llvm::PtxKernel - } else { - panic!("Architecture {arch} does not support GpuKernel calling convention"); - } - } + CanonAbi::GpuKernel => match sess.target.arch { + Arch::AmdGpu => llvm::AmdgpuKernel, + Arch::Nvptx64 => llvm::PtxKernel, + arch => panic!("Architecture {arch} does not support GpuKernel calling convention"), + }, CanonAbi::Interrupt(interrupt_kind) => match interrupt_kind { InterruptKind::Avr => llvm::AvrInterrupt, InterruptKind::AvrNonBlocking => llvm::AvrNonBlockingInterrupt, diff --git a/compiler/rustc_codegen_llvm/src/attributes.rs b/compiler/rustc_codegen_llvm/src/attributes.rs index ac20f9c64fa1a..ff9607e715ec2 100644 --- a/compiler/rustc_codegen_llvm/src/attributes.rs +++ b/compiler/rustc_codegen_llvm/src/attributes.rs @@ -7,7 +7,7 @@ use rustc_middle::middle::codegen_fn_attrs::{ use rustc_middle::ty::{self, TyCtxt}; use rustc_session::config::{BranchProtection, FunctionReturn, OptLevel, PAuthKey, PacRet}; use rustc_symbol_mangling::mangle_internal_symbol; -use rustc_target::spec::{FramePointer, SanitizerSet, StackProbeType, StackProtector}; +use rustc_target::spec::{Arch, FramePointer, SanitizerSet, StackProbeType, StackProtector}; use smallvec::SmallVec; use crate::context::SimpleCx; @@ -54,7 +54,7 @@ pub(crate) fn inline_attr<'ll, 'tcx>( Some(AttributeKind::AlwaysInline.create_attr(cx.llcx)) } InlineAttr::Never => { - if tcx.sess.target.arch != "amdgpu" { + if tcx.sess.target.arch != Arch::AmdGpu { Some(AttributeKind::NoInline.create_attr(cx.llcx)) } else { None @@ -287,7 +287,7 @@ fn stackprotector_attr<'ll>(cx: &SimpleCx<'ll>, sess: &Session) -> Option<&'ll A } fn backchain_attr<'ll>(cx: &SimpleCx<'ll>, sess: &Session) -> Option<&'ll Attribute> { - if sess.target.arch != "s390x" { + if sess.target.arch != Arch::S390x { return None; } @@ -423,7 +423,7 @@ pub(crate) fn llfn_attrs_from_instance<'ll, 'tcx>( if let Some(BranchProtection { bti, pac_ret, gcs }) = sess.opts.unstable_opts.branch_protection { - assert!(sess.target.arch == "aarch64"); + assert!(sess.target.arch == Arch::AArch64); if bti { to_add.push(llvm::CreateAttrString(cx.llcx, "branch-target-enforcement")); } diff --git a/compiler/rustc_codegen_llvm/src/back/write.rs b/compiler/rustc_codegen_llvm/src/back/write.rs index cfbb9541ecd2d..46f9b0020db32 100644 --- a/compiler/rustc_codegen_llvm/src/back/write.rs +++ b/compiler/rustc_codegen_llvm/src/back/write.rs @@ -25,7 +25,9 @@ use rustc_session::config::{ self, Lto, OutputType, Passes, RemapPathScopeComponents, SplitDwarfKind, SwitchWithOptPath, }; use rustc_span::{BytePos, InnerSpan, Pos, SpanData, SyntaxContext, sym}; -use rustc_target::spec::{CodeModel, FloatAbi, RelocModel, SanitizerSet, SplitDebuginfo, TlsModel}; +use rustc_target::spec::{ + Arch, CodeModel, FloatAbi, RelocModel, SanitizerSet, SplitDebuginfo, TlsModel, +}; use tracing::{debug, trace}; use crate::back::lto::ThinBuffer; @@ -206,7 +208,7 @@ pub(crate) fn target_machine_factory( let reloc_model = to_llvm_relocation_model(sess.relocation_model()); let (opt_level, _) = to_llvm_opt_settings(optlvl); - let float_abi = if sess.target.arch == "arm" && sess.opts.cg.soft_float { + let float_abi = if sess.target.arch == Arch::Arm && sess.opts.cg.soft_float { llvm::FloatAbi::Soft } else { // `validate_commandline_args_with_session_available` has already warned about this being diff --git a/compiler/rustc_codegen_llvm/src/builder.rs b/compiler/rustc_codegen_llvm/src/builder.rs index 49d38e05c8b06..d441cd119a747 100644 --- a/compiler/rustc_codegen_llvm/src/builder.rs +++ b/compiler/rustc_codegen_llvm/src/builder.rs @@ -26,7 +26,7 @@ use rustc_sanitizers::{cfi, kcfi}; use rustc_session::config::OptLevel; use rustc_span::Span; use rustc_target::callconv::{FnAbi, PassMode}; -use rustc_target::spec::{HasTargetSpec, SanitizerSet, Target}; +use rustc_target::spec::{Arch, HasTargetSpec, SanitizerSet, Target}; use smallvec::SmallVec; use tracing::{debug, instrument}; @@ -839,11 +839,10 @@ impl<'a, 'll, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> { // operation. But it's not clear how to do that with LLVM.) // For more context, see and // . - const WELL_BEHAVED_NONTEMPORAL_ARCHS: &[&str] = - &["aarch64", "arm", "riscv32", "riscv64"]; - - let use_nontemporal = - WELL_BEHAVED_NONTEMPORAL_ARCHS.contains(&&*self.cx.tcx.sess.target.arch); + let use_nontemporal = matches!( + self.cx.tcx.sess.target.arch, + Arch::AArch64 | Arch::Arm | Arch::RiscV32 | Arch::RiscV64 + ); if use_nontemporal { // According to LLVM [1] building a nontemporal store must // *always* point to a metadata value of the integer 1. diff --git a/compiler/rustc_codegen_llvm/src/callee.rs b/compiler/rustc_codegen_llvm/src/callee.rs index b86b32b92df04..f0d4c546e986b 100644 --- a/compiler/rustc_codegen_llvm/src/callee.rs +++ b/compiler/rustc_codegen_llvm/src/callee.rs @@ -7,6 +7,7 @@ use rustc_codegen_ssa::common; use rustc_middle::ty::layout::{FnAbiOf, HasTyCtxt, HasTypingEnv}; use rustc_middle::ty::{self, Instance, TypeVisitableExt}; +use rustc_target::spec::Arch; use tracing::debug; use crate::context::CodegenCx; @@ -35,7 +36,7 @@ pub(crate) fn get_fn<'ll, 'tcx>(cx: &CodegenCx<'ll, 'tcx>, instance: Instance<'t llfn } else { let instance_def_id = instance.def_id(); - let llfn = if tcx.sess.target.arch == "x86" + let llfn = if tcx.sess.target.arch == Arch::X86 && let Some(dllimport) = crate::common::get_dllimport(tcx, instance_def_id, sym) { // When calling functions in generated import libraries, MSVC needs diff --git a/compiler/rustc_codegen_llvm/src/consts.rs b/compiler/rustc_codegen_llvm/src/consts.rs index 9844c9444b3d0..08c53179bc142 100644 --- a/compiler/rustc_codegen_llvm/src/consts.rs +++ b/compiler/rustc_codegen_llvm/src/consts.rs @@ -17,6 +17,7 @@ use rustc_middle::ty::layout::{HasTypingEnv, LayoutOf}; use rustc_middle::ty::{self, Instance}; use rustc_middle::{bug, span_bug}; use rustc_span::Symbol; +use rustc_target::spec::Arch; use tracing::{debug, instrument, trace}; use crate::common::CodegenCx; @@ -203,7 +204,7 @@ fn check_and_apply_linkage<'ll, 'tcx>( llvm::set_linkage(g2, llvm::Linkage::InternalLinkage); llvm::set_initializer(g2, g1); g2 - } else if cx.tcx.sess.target.arch == "x86" + } else if cx.tcx.sess.target.arch == Arch::X86 && common::is_mingw_gnu_toolchain(&cx.tcx.sess.target) && let Some(dllimport) = crate::common::get_dllimport(cx.tcx, def_id, sym) { diff --git a/compiler/rustc_codegen_llvm/src/context.rs b/compiler/rustc_codegen_llvm/src/context.rs index 808aaceab4d20..c01f163f2ee19 100644 --- a/compiler/rustc_codegen_llvm/src/context.rs +++ b/compiler/rustc_codegen_llvm/src/context.rs @@ -28,7 +28,9 @@ use rustc_session::config::{ use rustc_span::source_map::Spanned; use rustc_span::{DUMMY_SP, Span, Symbol}; use rustc_symbol_mangling::mangle_internal_symbol; -use rustc_target::spec::{HasTargetSpec, RelocModel, SmallDataThresholdSupport, Target, TlsModel}; +use rustc_target::spec::{ + Arch, HasTargetSpec, RelocModel, SmallDataThresholdSupport, Target, TlsModel, +}; use smallvec::SmallVec; use crate::abi::to_llvm_calling_convention; @@ -181,22 +183,22 @@ pub(crate) unsafe fn create_module<'ll>( let llvm_version = llvm_util::get_version(); if llvm_version < (21, 0, 0) { - if sess.target.arch == "nvptx64" { + if sess.target.arch == Arch::Nvptx64 { // LLVM 21 updated the default layout on nvptx: https://github.com/llvm/llvm-project/pull/124961 target_data_layout = target_data_layout.replace("e-p6:32:32-i64", "e-i64"); } - if sess.target.arch == "amdgpu" { + if sess.target.arch == Arch::AmdGpu { // LLVM 21 adds the address width for address space 8. // See https://github.com/llvm/llvm-project/pull/139419 target_data_layout = target_data_layout.replace("p8:128:128:128:48", "p8:128:128") } } if llvm_version < (22, 0, 0) { - if sess.target.arch == "avr" { + if sess.target.arch == Arch::Avr { // LLVM 22.0 updated the default layout on avr: https://github.com/llvm/llvm-project/pull/153010 target_data_layout = target_data_layout.replace("n8:16", "n8") } - if sess.target.arch == "nvptx64" { + if sess.target.arch == Arch::Nvptx64 { // LLVM 22 updated the NVPTX layout to indicate 256-bit vector load/store: https://github.com/llvm/llvm-project/pull/155198 target_data_layout = target_data_layout.replace("-i256:256", ""); } @@ -371,7 +373,7 @@ pub(crate) unsafe fn create_module<'ll>( if let Some(BranchProtection { bti, pac_ret, gcs }) = sess.opts.unstable_opts.branch_protection { - if sess.target.arch == "aarch64" { + if sess.target.arch == Arch::AArch64 { llvm::add_module_flag_u32( llmod, llvm::ModuleFlagMergeBehavior::Min, @@ -502,7 +504,7 @@ pub(crate) unsafe fn create_module<'ll>( // FIXME: https://github.com/llvm/llvm-project/issues/50591 // If llvm_abiname is empty, emit nothing. let llvm_abiname = &sess.target.options.llvm_abiname; - if matches!(sess.target.arch.as_ref(), "riscv32" | "riscv64") && !llvm_abiname.is_empty() { + if matches!(sess.target.arch, Arch::RiscV32 | Arch::RiscV64) && !llvm_abiname.is_empty() { llvm::add_module_flag_str( llmod, llvm::ModuleFlagMergeBehavior::Error, @@ -667,7 +669,7 @@ impl<'ll, 'tcx> CodegenCx<'ll, 'tcx> { /// This corresponds to the `-fobjc-abi-version=` flag in Clang / GCC. pub(crate) fn objc_abi_version(&self) -> u32 { assert!(self.tcx.sess.target.is_like_darwin); - if self.tcx.sess.target.arch == "x86" && self.tcx.sess.target.os == "macos" { + if self.tcx.sess.target.arch == Arch::X86 && self.tcx.sess.target.os == "macos" { // 32-bit x86 macOS uses ABI version 1 (a.k.a. the "fragile ABI"). 1 } else { diff --git a/compiler/rustc_codegen_llvm/src/llvm_util.rs b/compiler/rustc_codegen_llvm/src/llvm_util.rs index 0fcad0376b11c..8f8a3a3aef2ff 100644 --- a/compiler/rustc_codegen_llvm/src/llvm_util.rs +++ b/compiler/rustc_codegen_llvm/src/llvm_util.rs @@ -15,7 +15,7 @@ use rustc_fs_util::path_to_c_string; use rustc_middle::bug; use rustc_session::Session; use rustc_session::config::{PrintKind, PrintRequest}; -use rustc_target::spec::{MergeFunctions, PanicStrategy, SmallDataThresholdSupport}; +use rustc_target::spec::{Arch, MergeFunctions, PanicStrategy, SmallDataThresholdSupport}; use smallvec::{SmallVec, smallvec}; use crate::back::write::create_informational_target_machine; @@ -217,70 +217,85 @@ impl<'a> IntoIterator for LLVMFeature<'a> { /// Rust can also be build with an external precompiled version of LLVM which might lead to failures /// if the oldest tested / supported LLVM version doesn't yet support the relevant intrinsics. pub(crate) fn to_llvm_features<'a>(sess: &Session, s: &'a str) -> Option> { - let raw_arch = &*sess.target.arch; - let arch = match raw_arch { - "x86_64" => "x86", - "arm64ec" => "aarch64", - "sparc64" => "sparc", - "powerpc64" => "powerpc", - _ => raw_arch, - }; let (major, _, _) = get_version(); - match (arch, s) { - ("aarch64", "rcpc2") => Some(LLVMFeature::new("rcpc-immo")), - ("aarch64", "dpb") => Some(LLVMFeature::new("ccpp")), - ("aarch64", "dpb2") => Some(LLVMFeature::new("ccdp")), - ("aarch64", "frintts") => Some(LLVMFeature::new("fptoint")), - ("aarch64", "fcma") => Some(LLVMFeature::new("complxnum")), - ("aarch64", "pmuv3") => Some(LLVMFeature::new("perfmon")), - ("aarch64", "paca") => Some(LLVMFeature::new("pauth")), - ("aarch64", "pacg") => Some(LLVMFeature::new("pauth")), - ("aarch64", "flagm2") => Some(LLVMFeature::new("altnzcv")), - // Rust ties fp and neon together. - ("aarch64", "neon") => Some(LLVMFeature::with_dependencies( - "neon", - smallvec![TargetFeatureFoldStrength::Both("fp-armv8")], - )), - // In LLVM neon implicitly enables fp, but we manually enable - // neon when a feature only implicitly enables fp - ("aarch64", "fhm") => Some(LLVMFeature::new("fp16fml")), - ("aarch64", "fp16") => Some(LLVMFeature::new("fullfp16")), - // Filter out features that are not supported by the current LLVM version - ("aarch64", "fpmr") => None, // only existed in 18 - ("arm", "fp16") => Some(LLVMFeature::new("fullfp16")), + match sess.target.arch { + Arch::AArch64 | Arch::Arm64EC => { + match s { + "rcpc2" => Some(LLVMFeature::new("rcpc-immo")), + "dpb" => Some(LLVMFeature::new("ccpp")), + "dpb2" => Some(LLVMFeature::new("ccdp")), + "frintts" => Some(LLVMFeature::new("fptoint")), + "fcma" => Some(LLVMFeature::new("complxnum")), + "pmuv3" => Some(LLVMFeature::new("perfmon")), + "paca" => Some(LLVMFeature::new("pauth")), + "pacg" => Some(LLVMFeature::new("pauth")), + "flagm2" => Some(LLVMFeature::new("altnzcv")), + // Rust ties fp and neon together. + "neon" => Some(LLVMFeature::with_dependencies( + "neon", + smallvec![TargetFeatureFoldStrength::Both("fp-armv8")], + )), + // In LLVM neon implicitly enables fp, but we manually enable + // neon when a feature only implicitly enables fp + "fhm" => Some(LLVMFeature::new("fp16fml")), + "fp16" => Some(LLVMFeature::new("fullfp16")), + // Filter out features that are not supported by the current LLVM version + "fpmr" => None, // only existed in 18 + s => Some(LLVMFeature::new(s)), + } + } + Arch::Arm => match s { + "fp16" => Some(LLVMFeature::new("fullfp16")), + s => Some(LLVMFeature::new(s)), + }, + // Filter out features that are not supported by the current LLVM version - ("loongarch32" | "loongarch64", "32s") if major < 21 => None, - ("powerpc", "power8-crypto") => Some(LLVMFeature::new("crypto")), - ("sparc", "leoncasa") => Some(LLVMFeature::new("hasleoncasa")), - ("x86", "sse4.2") => Some(LLVMFeature::with_dependencies( - "sse4.2", - smallvec![TargetFeatureFoldStrength::EnableOnly("crc32")], - )), - ("x86", "pclmulqdq") => Some(LLVMFeature::new("pclmul")), - ("x86", "rdrand") => Some(LLVMFeature::new("rdrnd")), - ("x86", "bmi1") => Some(LLVMFeature::new("bmi")), - ("x86", "cmpxchg16b") => Some(LLVMFeature::new("cx16")), - ("x86", "lahfsahf") => Some(LLVMFeature::new("sahf")), - // Enable the evex512 target feature if an avx512 target feature is enabled. - ("x86", s) if s.starts_with("avx512") => Some(LLVMFeature::with_dependencies( - s, - smallvec![TargetFeatureFoldStrength::EnableOnly("evex512")], - )), - ("x86", "avx10.1") => Some(LLVMFeature::new("avx10.1-512")), - ("x86", "avx10.2") => Some(LLVMFeature::new("avx10.2-512")), - ("x86", "apxf") => Some(LLVMFeature::with_dependencies( - "egpr", - smallvec![ - TargetFeatureFoldStrength::Both("push2pop2"), - TargetFeatureFoldStrength::Both("ppx"), - TargetFeatureFoldStrength::Both("ndd"), - TargetFeatureFoldStrength::Both("ccmp"), - TargetFeatureFoldStrength::Both("cf"), - TargetFeatureFoldStrength::Both("nf"), - TargetFeatureFoldStrength::Both("zu"), - ], - )), - (_, s) => Some(LLVMFeature::new(s)), + Arch::LoongArch32 | Arch::LoongArch64 => match s { + "32s" if major < 21 => None, + s => Some(LLVMFeature::new(s)), + }, + Arch::PowerPC | Arch::PowerPC64 => match s { + "power8-crypto" => Some(LLVMFeature::new("crypto")), + s => Some(LLVMFeature::new(s)), + }, + Arch::Sparc | Arch::Sparc64 => match s { + "leoncasa" => Some(LLVMFeature::new("hasleoncasa")), + s => Some(LLVMFeature::new(s)), + }, + Arch::X86 | Arch::X86_64 => { + match s { + "sse4.2" => Some(LLVMFeature::with_dependencies( + "sse4.2", + smallvec![TargetFeatureFoldStrength::EnableOnly("crc32")], + )), + "pclmulqdq" => Some(LLVMFeature::new("pclmul")), + "rdrand" => Some(LLVMFeature::new("rdrnd")), + "bmi1" => Some(LLVMFeature::new("bmi")), + "cmpxchg16b" => Some(LLVMFeature::new("cx16")), + "lahfsahf" => Some(LLVMFeature::new("sahf")), + // Enable the evex512 target feature if an avx512 target feature is enabled. + s if s.starts_with("avx512") => Some(LLVMFeature::with_dependencies( + s, + smallvec![TargetFeatureFoldStrength::EnableOnly("evex512")], + )), + "avx10.1" => Some(LLVMFeature::new("avx10.1-512")), + "avx10.2" => Some(LLVMFeature::new("avx10.2-512")), + "apxf" => Some(LLVMFeature::with_dependencies( + "egpr", + smallvec![ + TargetFeatureFoldStrength::Both("push2pop2"), + TargetFeatureFoldStrength::Both("ppx"), + TargetFeatureFoldStrength::Both("ndd"), + TargetFeatureFoldStrength::Both("ccmp"), + TargetFeatureFoldStrength::Both("cf"), + TargetFeatureFoldStrength::Both("nf"), + TargetFeatureFoldStrength::Both("zu"), + ], + )), + s => Some(LLVMFeature::new(s)), + } + } + _ => Some(LLVMFeature::new(s)), } } @@ -327,7 +342,7 @@ pub(crate) fn target_config(sess: &Session) -> TargetConfig { /// Determine whether or not experimental float types are reliable based on known bugs. fn update_target_reliable_float_cfg(sess: &Session, cfg: &mut TargetConfig) { - let target_arch = sess.target.arch.as_ref(); + let target_arch = sess.target.arch; let target_os = sess.target.options.os.as_ref(); let target_env = sess.target.options.env.as_ref(); let target_abi = sess.target.options.abi.as_ref(); @@ -338,23 +353,23 @@ fn update_target_reliable_float_cfg(sess: &Session, cfg: &mut TargetConfig) { cfg.has_reliable_f16 = match (target_arch, target_os) { // LLVM crash without neon (fixed in llvm20) - ("aarch64", _) + (Arch::AArch64, _) if !cfg.target_features.iter().any(|f| f.as_str() == "neon") && lt_20_1_1 => { false } // Unsupported - ("arm64ec", _) => false, + (Arch::Arm64EC, _) => false, // Selection failure (fixed in llvm21) - ("s390x", _) if lt_21_0_0 => false, + (Arch::S390x, _) if lt_21_0_0 => false, // MinGW ABI bugs - ("x86_64", "windows") if target_env == "gnu" && target_abi != "llvm" => false, + (Arch::X86_64, "windows") if target_env == "gnu" && target_abi != "llvm" => false, // Infinite recursion - ("csky", _) => false, - ("hexagon", _) if lt_21_0_0 => false, // (fixed in llvm21) - ("powerpc" | "powerpc64", _) => false, - ("sparc" | "sparc64", _) => false, - ("wasm32" | "wasm64", _) => false, + (Arch::CSky, _) => false, + (Arch::Hexagon, _) if lt_21_0_0 => false, // (fixed in llvm21) + (Arch::PowerPC | Arch::PowerPC64, _) => false, + (Arch::Sparc | Arch::Sparc64, _) => false, + (Arch::Wasm32 | Arch::Wasm64, _) => false, // `f16` support only requires that symbols converting to and from `f32` are available. We // provide these in `compiler-builtins`, so `f16` should be available on all platforms that // do not have other ABI issues or LLVM crashes. @@ -363,24 +378,24 @@ fn update_target_reliable_float_cfg(sess: &Session, cfg: &mut TargetConfig) { cfg.has_reliable_f128 = match (target_arch, target_os) { // Unsupported - ("arm64ec", _) => false, + (Arch::Arm64EC, _) => false, // Selection bug (fixed in llvm20) - ("mips64" | "mips64r6", _) if lt_20_1_1 => false, + (Arch::Mips64 | Arch::Mips64r6, _) if lt_20_1_1 => false, // Selection bug . This issue is closed // but basic math still does not work. - ("nvptx64", _) => false, + (Arch::Nvptx64, _) => false, // Unsupported https://github.com/llvm/llvm-project/issues/121122 - ("amdgpu", _) => false, + (Arch::AmdGpu, _) => false, // ABI bugs et al. (full // list at ) - ("powerpc" | "powerpc64", _) => false, + (Arch::PowerPC | Arch::PowerPC64, _) => false, // ABI unsupported - ("sparc", _) => false, + (Arch::Sparc, _) => false, // Stack alignment bug . NB: tests may // not fail if our compiler-builtins is linked. (fixed in llvm21) - ("x86", _) if lt_21_0_0 => false, + (Arch::X86, _) if lt_21_0_0 => false, // MinGW ABI bugs - ("x86_64", "windows") if target_env == "gnu" && target_abi != "llvm" => false, + (Arch::X86_64, "windows") if target_env == "gnu" && target_abi != "llvm" => false, // There are no known problems on other platforms, so the only requirement is that symbols // are available. `compiler-builtins` provides all symbols required for core `f128` // support, so this should work for everything else. @@ -402,7 +417,7 @@ fn update_target_reliable_float_cfg(sess: &Session, cfg: &mut TargetConfig) { // // musl does not implement the symbols required for f128 math at all. _ if target_env == "musl" => false, - ("x86_64", _) => false, + (Arch::X86_64, _) => false, (_, "linux") if target_pointer_width == 64 => true, _ => false, } && cfg.has_reliable_f128; @@ -605,8 +620,8 @@ fn llvm_features_by_flags(sess: &Session, features: &mut Vec) { // -Zfixed-x18 if sess.opts.unstable_opts.fixed_x18 { - if sess.target.arch != "aarch64" { - sess.dcx().emit_fatal(errors::FixedX18InvalidArch { arch: &sess.target.arch }); + if sess.target.arch != Arch::AArch64 { + sess.dcx().emit_fatal(errors::FixedX18InvalidArch { arch: sess.target.arch.desc() }); } else { features.push("+reserve-x18".into()); } diff --git a/compiler/rustc_codegen_llvm/src/mono_item.rs b/compiler/rustc_codegen_llvm/src/mono_item.rs index 52eefe2d4d243..4184ced749624 100644 --- a/compiler/rustc_codegen_llvm/src/mono_item.rs +++ b/compiler/rustc_codegen_llvm/src/mono_item.rs @@ -7,7 +7,7 @@ use rustc_middle::mir::mono::Visibility; use rustc_middle::ty::layout::{FnAbiOf, HasTypingEnv, LayoutOf}; use rustc_middle::ty::{self, Instance, TypeVisitableExt}; use rustc_session::config::CrateType; -use rustc_target::spec::RelocModel; +use rustc_target::spec::{Arch, RelocModel}; use tracing::debug; use crate::context::CodegenCx; @@ -116,7 +116,7 @@ impl CodegenCx<'_, '_> { } // PowerPC64 prefers TOC indirection to avoid copy relocations. - if matches!(&*self.tcx.sess.target.arch, "powerpc64" | "powerpc64le") { + if matches!(self.tcx.sess.target.arch, Arch::PowerPC64 | Arch::PowerPC64LE) { return false; } diff --git a/compiler/rustc_codegen_llvm/src/va_arg.rs b/compiler/rustc_codegen_llvm/src/va_arg.rs index 2d9abb412d4f1..115d96d9baf65 100644 --- a/compiler/rustc_codegen_llvm/src/va_arg.rs +++ b/compiler/rustc_codegen_llvm/src/va_arg.rs @@ -7,6 +7,7 @@ use rustc_codegen_ssa::traits::{ }; use rustc_middle::ty::Ty; use rustc_middle::ty::layout::{HasTyCtxt, LayoutOf}; +use rustc_target::spec::Arch; use crate::builder::Builder; use crate::llvm::{Type, Value}; @@ -886,8 +887,8 @@ pub(super) fn emit_va_arg<'ll, 'tcx>( // is lacking in some instances, so we should only use it as a fallback. let target = &bx.cx.tcx.sess.target; - match &*target.arch { - "x86" => emit_ptr_va_arg( + match target.arch { + Arch::X86 => emit_ptr_va_arg( bx, addr, target_ty, @@ -896,7 +897,7 @@ pub(super) fn emit_va_arg<'ll, 'tcx>( if target.is_like_windows { AllowHigherAlign::No } else { AllowHigherAlign::Yes }, ForceRightAdjust::No, ), - "aarch64" | "arm64ec" if target.is_like_windows || target.is_like_darwin => { + Arch::AArch64 | Arch::Arm64EC if target.is_like_windows || target.is_like_darwin => { emit_ptr_va_arg( bx, addr, @@ -907,8 +908,8 @@ pub(super) fn emit_va_arg<'ll, 'tcx>( ForceRightAdjust::No, ) } - "aarch64" => emit_aapcs_va_arg(bx, addr, target_ty), - "arm" => { + Arch::AArch64 => emit_aapcs_va_arg(bx, addr, target_ty), + Arch::Arm => { // Types wider than 16 bytes are not currently supported. Clang has special logic for // such types, but `VaArgSafe` is not implemented for any type that is this large. assert!(bx.cx.size_of(target_ty).bytes() <= 16); @@ -923,22 +924,28 @@ pub(super) fn emit_va_arg<'ll, 'tcx>( ForceRightAdjust::No, ) } - "s390x" => emit_s390x_va_arg(bx, addr, target_ty), - "powerpc" => emit_powerpc_va_arg(bx, addr, target_ty), - "powerpc64" | "powerpc64le" => emit_ptr_va_arg( + Arch::S390x => emit_s390x_va_arg(bx, addr, target_ty), + Arch::PowerPC => emit_powerpc_va_arg(bx, addr, target_ty), + Arch::PowerPC64 => emit_ptr_va_arg( bx, addr, target_ty, PassMode::Direct, SlotSize::Bytes8, AllowHigherAlign::Yes, - match &*target.arch { - "powerpc64" => ForceRightAdjust::Yes, - _ => ForceRightAdjust::No, - }, + ForceRightAdjust::Yes, + ), + Arch::PowerPC64LE => emit_ptr_va_arg( + bx, + addr, + target_ty, + PassMode::Direct, + SlotSize::Bytes8, + AllowHigherAlign::Yes, + ForceRightAdjust::No, ), // Windows x86_64 - "x86_64" if target.is_like_windows => { + Arch::X86_64 if target.is_like_windows => { let target_ty_size = bx.cx.size_of(target_ty).bytes(); emit_ptr_va_arg( bx, @@ -955,8 +962,8 @@ pub(super) fn emit_va_arg<'ll, 'tcx>( ) } // This includes `target.is_like_darwin`, which on x86_64 targets is like sysv64. - "x86_64" => emit_x86_64_sysv64_va_arg(bx, addr, target_ty), - "xtensa" => emit_xtensa_va_arg(bx, addr, target_ty), + Arch::X86_64 => emit_x86_64_sysv64_va_arg(bx, addr, target_ty), + Arch::Xtensa => emit_xtensa_va_arg(bx, addr, target_ty), // For all other architecture/OS combinations fall back to using // the LLVM va_arg instruction. // https://llvm.org/docs/LangRef.html#va-arg-instruction diff --git a/compiler/rustc_codegen_ssa/src/back/apple.rs b/compiler/rustc_codegen_ssa/src/back/apple.rs index b1d646d9265ff..3b29ddeadc7f6 100644 --- a/compiler/rustc_codegen_ssa/src/back/apple.rs +++ b/compiler/rustc_codegen_ssa/src/back/apple.rs @@ -5,8 +5,8 @@ use std::process::Command; use itertools::Itertools; use rustc_middle::middle::exported_symbols::SymbolExportKind; use rustc_session::Session; -use rustc_target::spec::Target; pub(super) use rustc_target::spec::apple::OSVersion; +use rustc_target::spec::{Arch, Target}; use tracing::debug; use crate::errors::{XcrunError, XcrunSdkPathWarning}; @@ -95,7 +95,7 @@ pub(super) fn add_data_and_relocation( pointer_width => unimplemented!("unsupported Apple pointer width {pointer_width:?}"), }; - if target.arch == "x86_64" { + if target.arch == Arch::X86_64 { // Force alignment for the entire section to be 16 on x86_64. file.section_mut(section).append_data(&[], 16); } else { @@ -111,7 +111,7 @@ pub(super) fn add_data_and_relocation( r_pcrel: false, r_length: 3, } - } else if target.arch == "arm" { + } else if target.arch == Arch::Arm { // FIXME(madsmtm): Remove once `object` supports 32-bit ARM relocations: // https://github.com/gimli-rs/object/pull/757 object::write::RelocationFlags::MachO { diff --git a/compiler/rustc_codegen_ssa/src/back/archive.rs b/compiler/rustc_codegen_ssa/src/back/archive.rs index cfd8ceac3a604..cef7df44abe30 100644 --- a/compiler/rustc_codegen_ssa/src/back/archive.rs +++ b/compiler/rustc_codegen_ssa/src/back/archive.rs @@ -17,6 +17,7 @@ use rustc_fs_util::TempDirBuilder; use rustc_metadata::EncodedMetadata; use rustc_session::Session; use rustc_span::Symbol; +use rustc_target::spec::Arch; use tracing::trace; use super::metadata::{create_compressed_metadata_file, search_for_section}; @@ -42,7 +43,7 @@ pub struct ImportLibraryItem { impl ImportLibraryItem { fn into_coff_short_export(self, sess: &Session) -> COFFShortExport { - let import_name = (sess.target.arch == "arm64ec").then(|| self.name.clone()); + let import_name = (sess.target.arch == Arch::Arm64EC).then(|| self.name.clone()); COFFShortExport { name: self.name, ext_name: None, @@ -117,12 +118,12 @@ pub trait ArchiveBuilderBuilder { let exports = items.into_iter().map(|item| item.into_coff_short_export(sess)).collect::>(); - let machine = match &*sess.target.arch { - "x86_64" => MachineTypes::AMD64, - "x86" => MachineTypes::I386, - "aarch64" => MachineTypes::ARM64, - "arm64ec" => MachineTypes::ARM64EC, - "arm" => MachineTypes::ARMNT, + let machine = match sess.target.arch { + Arch::X86_64 => MachineTypes::AMD64, + Arch::X86 => MachineTypes::I386, + Arch::AArch64 => MachineTypes::ARM64, + Arch::Arm64EC => MachineTypes::ARM64EC, + Arch::Arm => MachineTypes::ARMNT, cpu => panic!("unsupported cpu type {cpu}"), }; @@ -223,12 +224,12 @@ fn create_mingw_dll_import_lib( }; // dlltool target architecture args from: // https://github.com/llvm/llvm-project-release-prs/blob/llvmorg-15.0.6/llvm/lib/ToolDrivers/llvm-dlltool/DlltoolDriver.cpp#L69 - let (dlltool_target_arch, dlltool_target_bitness) = match sess.target.arch.as_ref() { - "x86_64" => ("i386:x86-64", "--64"), - "x86" => ("i386", "--32"), - "aarch64" => ("arm64", "--64"), - "arm" => ("arm", "--32"), - _ => panic!("unsupported arch {}", sess.target.arch), + let (dlltool_target_arch, dlltool_target_bitness) = match sess.target.arch { + Arch::X86_64 => ("i386:x86-64", "--64"), + Arch::X86 => ("i386", "--32"), + Arch::AArch64 => ("arm64", "--64"), + Arch::Arm => ("arm", "--32"), + arch => panic!("unsupported arch {arch}"), }; let mut dlltool_cmd = std::process::Command::new(&dlltool); dlltool_cmd @@ -281,10 +282,10 @@ fn find_binutils_dlltool(sess: &Session) -> OsString { "dlltool.exe" } else { // On other platforms, use the architecture-specific name. - match sess.target.arch.as_ref() { - "x86_64" => "x86_64-w64-mingw32-dlltool", - "x86" => "i686-w64-mingw32-dlltool", - "aarch64" => "aarch64-w64-mingw32-dlltool", + match sess.target.arch { + Arch::X86_64 => "x86_64-w64-mingw32-dlltool", + Arch::X86 => "i686-w64-mingw32-dlltool", + Arch::AArch64 => "aarch64-w64-mingw32-dlltool", // For non-standard architectures (e.g., aarch32) fallback to "dlltool". _ => "dlltool", @@ -378,9 +379,9 @@ pub fn try_extract_macho_fat_archive( archive_path: &Path, ) -> io::Result> { let archive_map = unsafe { Mmap::map(File::open(&archive_path)?)? }; - let target_arch = match sess.target.arch.as_ref() { - "aarch64" => object::Architecture::Aarch64, - "x86_64" => object::Architecture::X86_64, + let target_arch = match sess.target.arch { + Arch::AArch64 => object::Architecture::Aarch64, + Arch::X86_64 => object::Architecture::X86_64, _ => return Ok(None), }; @@ -531,7 +532,7 @@ impl<'a> ArArchiveBuilder<'a> { &entries, archive_kind, false, - /* is_ec = */ Some(self.sess.target.arch == "arm64ec"), + /* is_ec = */ Some(self.sess.target.arch == Arch::Arm64EC), )?; archive_tmpfile.flush()?; drop(archive_tmpfile); diff --git a/compiler/rustc_codegen_ssa/src/back/link.rs b/compiler/rustc_codegen_ssa/src/back/link.rs index ea538d3d46981..1124b0ac1aee5 100644 --- a/compiler/rustc_codegen_ssa/src/back/link.rs +++ b/compiler/rustc_codegen_ssa/src/back/link.rs @@ -883,7 +883,8 @@ fn link_natively( if is_msvc_link_exe && (code < 1000 || code > 9999) { let is_vs_installed = find_msvc_tools::find_vs_version().is_ok(); let has_linker = - find_msvc_tools::find_tool(&sess.target.arch, "link.exe").is_some(); + find_msvc_tools::find_tool(sess.target.arch.desc(), "link.exe") + .is_some(); sess.dcx().emit_note(errors::LinkExeUnexpectedError); diff --git a/compiler/rustc_codegen_ssa/src/back/link/raw_dylib.rs b/compiler/rustc_codegen_ssa/src/back/link/raw_dylib.rs index 7321bc1da391a..45c217168a8d9 100644 --- a/compiler/rustc_codegen_ssa/src/back/link/raw_dylib.rs +++ b/compiler/rustc_codegen_ssa/src/back/link/raw_dylib.rs @@ -11,6 +11,7 @@ use rustc_hir::attrs::NativeLibKind; use rustc_session::Session; use rustc_session::cstore::DllImport; use rustc_span::Symbol; +use rustc_target::spec::Arch; use crate::back::archive::ImportLibraryItem; use crate::back::link::ArchiveBuilderBuilder; @@ -77,7 +78,7 @@ pub(super) fn create_raw_dylib_dll_import_libs<'a>( let items: Vec = raw_dylib_imports .iter() .map(|import: &DllImport| { - if sess.target.arch == "x86" { + if sess.target.arch == Arch::X86 { ImportLibraryItem { name: common::i686_decorated_name( import, diff --git a/compiler/rustc_codegen_ssa/src/back/linker.rs b/compiler/rustc_codegen_ssa/src/back/linker.rs index ac12314373828..eb2740d59b4b5 100644 --- a/compiler/rustc_codegen_ssa/src/back/linker.rs +++ b/compiler/rustc_codegen_ssa/src/back/linker.rs @@ -17,7 +17,7 @@ use rustc_middle::middle::exported_symbols::{ use rustc_middle::ty::TyCtxt; use rustc_session::Session; use rustc_session::config::{self, CrateType, DebugInfo, LinkerPluginLto, Lto, OptLevel, Strip}; -use rustc_target::spec::{Cc, LinkOutputKind, LinkerFlavor, Lld}; +use rustc_target::spec::{Arch, Cc, LinkOutputKind, LinkerFlavor, Lld}; use tracing::{debug, warn}; use super::command::Command; @@ -53,7 +53,7 @@ pub(crate) fn get_linker<'a>( target_cpu: &'a str, codegen_backend: &'static str, ) -> Box { - let msvc_tool = find_msvc_tools::find_tool(&sess.target.arch, "link.exe"); + let msvc_tool = find_msvc_tools::find_tool(sess.target.arch.desc(), "link.exe"); // If our linker looks like a batch script on Windows then to execute this // we'll need to spawn `cmd` explicitly. This is primarily done to handle @@ -87,11 +87,11 @@ pub(crate) fn get_linker<'a>( if let Some(ref tool) = msvc_tool { let original_path = tool.path(); if let Some(root_lib_path) = original_path.ancestors().nth(4) { - let arch = match t.arch.as_ref() { - "x86_64" => Some("x64"), - "x86" => Some("x86"), - "aarch64" => Some("arm64"), - "arm" => Some("arm"), + let arch = match t.arch { + Arch::X86_64 => Some("x64"), + Arch::X86 => Some("x86"), + Arch::AArch64 => Some("arm64"), + Arch::Arm => Some("arm"), _ => None, }; if let Some(ref a) = arch { @@ -589,7 +589,7 @@ impl<'a> Linker for GccLinker<'a> { // // Currently this makes sense only when using avr-gcc as a linker, since // it brings a couple of hand-written important intrinsics from libgcc. - if self.sess.target.arch == "avr" && !self.uses_lld { + if self.sess.target.arch == Arch::Avr && !self.uses_lld { self.verbatim_arg(format!("-mmcu={}", self.target_cpu)); } } diff --git a/compiler/rustc_codegen_ssa/src/back/symbol_export.rs b/compiler/rustc_codegen_ssa/src/back/symbol_export.rs index d9ba5017a422d..6fa8725a78713 100644 --- a/compiler/rustc_codegen_ssa/src/back/symbol_export.rs +++ b/compiler/rustc_codegen_ssa/src/back/symbol_export.rs @@ -17,7 +17,7 @@ use rustc_middle::ty::{self, GenericArgKind, GenericArgsRef, Instance, SymbolNam use rustc_middle::util::Providers; use rustc_session::config::{CrateType, OomStrategy}; use rustc_symbol_mangling::mangle_internal_symbol; -use rustc_target::spec::TlsModel; +use rustc_target::spec::{Arch, TlsModel}; use tracing::debug; use crate::back::symbol_export; @@ -659,11 +659,11 @@ pub(crate) fn linking_symbol_name_for_instance_in_crate<'tcx>( return undecorated; } - let prefix = match &target.arch[..] { - "x86" => Some('_'), - "x86_64" => None, + let prefix = match target.arch { + Arch::X86 => Some('_'), + Arch::X86_64 => None, // Only functions are decorated for arm64ec. - "arm64ec" if export_kind == SymbolExportKind::Text => Some('#'), + Arch::Arm64EC if export_kind == SymbolExportKind::Text => Some('#'), // Only x86/64 and arm64ec use symbol decorations. _ => return undecorated, }; diff --git a/compiler/rustc_codegen_ssa/src/base.rs b/compiler/rustc_codegen_ssa/src/base.rs index f58be0a3b9a3a..a500547587291 100644 --- a/compiler/rustc_codegen_ssa/src/base.rs +++ b/compiler/rustc_codegen_ssa/src/base.rs @@ -33,6 +33,7 @@ use rustc_session::Session; use rustc_session::config::{self, CrateType, EntryFnType}; use rustc_span::{DUMMY_SP, Symbol, sym}; use rustc_symbol_mangling::mangle_internal_symbol; +use rustc_target::spec::Arch; use rustc_trait_selection::infer::{BoundRegionConversionTime, TyCtxtInferExt}; use rustc_trait_selection::traits::{ObligationCause, ObligationCtxt}; use tracing::{debug, info}; @@ -982,9 +983,9 @@ impl CrateInfo { // by the compiler, but that's ok because all this stuff is unstable anyway. let target = &tcx.sess.target; if !are_upstream_rust_objects_already_included(tcx.sess) { - let add_prefix = match (target.is_like_windows, target.arch.as_ref()) { - (true, "x86") => |name: String, _: SymbolExportKind| format!("_{name}"), - (true, "arm64ec") => { + let add_prefix = match (target.is_like_windows, target.arch) { + (true, Arch::X86) => |name: String, _: SymbolExportKind| format!("_{name}"), + (true, Arch::Arm64EC) => { // Only functions are decorated for arm64ec. |name: String, export_kind: SymbolExportKind| match export_kind { SymbolExportKind::Text => format!("#{name}"), diff --git a/compiler/rustc_codegen_ssa/src/mir/intrinsic.rs b/compiler/rustc_codegen_ssa/src/mir/intrinsic.rs index cc3316c7f8cc0..aeb7401182347 100644 --- a/compiler/rustc_codegen_ssa/src/mir/intrinsic.rs +++ b/compiler/rustc_codegen_ssa/src/mir/intrinsic.rs @@ -4,6 +4,7 @@ use rustc_middle::ty::{self, Ty, TyCtxt}; use rustc_middle::{bug, span_bug}; use rustc_session::config::OptLevel; use rustc_span::sym; +use rustc_target::spec::Arch; use super::FunctionCx; use super::operand::OperandRef; @@ -79,7 +80,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { // reinterpretation of values as (chunkable) byte arrays, and the loop in the // block optimization in `ptr::swap_nonoverlapping` is hard to rewrite back // into the (unoptimized) direct swapping implementation, so we disable it. - || bx.sess().target.arch == "spirv" + || bx.sess().target.arch == Arch::SpirV { let align = pointee_layout.align.abi; let x_place = args[0].val.deref(align); diff --git a/compiler/rustc_codegen_ssa/src/mir/naked_asm.rs b/compiler/rustc_codegen_ssa/src/mir/naked_asm.rs index e7239ebfecf63..4a47799b2bdc3 100644 --- a/compiler/rustc_codegen_ssa/src/mir/naked_asm.rs +++ b/compiler/rustc_codegen_ssa/src/mir/naked_asm.rs @@ -7,7 +7,7 @@ use rustc_middle::ty::{Instance, Ty, TyCtxt, TypeVisitableExt}; use rustc_middle::{bug, ty}; use rustc_span::sym; use rustc_target::callconv::{ArgAbi, FnAbi, PassMode}; -use rustc_target::spec::BinaryFormat; +use rustc_target::spec::{Arch, BinaryFormat}; use crate::common; use crate::mir::AsmCodegenMethods; @@ -125,7 +125,7 @@ fn prefix_and_suffix<'tcx>( let asm_binary_format = &tcx.sess.target.binary_format; - let is_arm = tcx.sess.target.arch == "arm"; + let is_arm = tcx.sess.target.arch == Arch::Arm; let is_thumb = tcx.sess.unstable_target_features.contains(&sym::thumb_mode); let attrs = tcx.codegen_instance_attrs(instance.def); diff --git a/compiler/rustc_codegen_ssa/src/target_features.rs b/compiler/rustc_codegen_ssa/src/target_features.rs index 54584999d61b6..9b86fa961617d 100644 --- a/compiler/rustc_codegen_ssa/src/target_features.rs +++ b/compiler/rustc_codegen_ssa/src/target_features.rs @@ -10,6 +10,7 @@ use rustc_session::Session; use rustc_session::lint::builtin::AARCH64_SOFTFLOAT_NEON; use rustc_session::parse::feature_err; use rustc_span::{Span, Symbol, sym}; +use rustc_target::spec::Arch; use rustc_target::target_features::{RUSTC_SPECIFIC_FEATURES, Stability}; use smallvec::SmallVec; @@ -73,7 +74,7 @@ pub(crate) fn from_target_feature_attr( if abi_feature_constraints.incompatible.contains(&name.as_str()) { // For "neon" specifically, we emit an FCW instead of a hard error. // See . - if tcx.sess.target.arch == "aarch64" && name.as_str() == "neon" { + if tcx.sess.target.arch == Arch::AArch64 && name.as_str() == "neon" { tcx.emit_node_span_lint( AARCH64_SOFTFLOAT_NEON, tcx.local_def_id_to_hir_id(did), diff --git a/compiler/rustc_metadata/src/native_libs.rs b/compiler/rustc_metadata/src/native_libs.rs index 15572063d45a6..8f51cbe0217cb 100644 --- a/compiler/rustc_metadata/src/native_libs.rs +++ b/compiler/rustc_metadata/src/native_libs.rs @@ -15,7 +15,7 @@ use rustc_session::cstore::{DllCallingConvention, DllImport, ForeignModule, Nati use rustc_session::search_paths::PathKind; use rustc_span::Symbol; use rustc_span::def_id::{DefId, LOCAL_CRATE}; -use rustc_target::spec::{BinaryFormat, LinkSelfContainedComponents}; +use rustc_target::spec::{Arch, BinaryFormat, LinkSelfContainedComponents}; use crate::errors; @@ -393,7 +393,7 @@ impl<'tcx> Collector<'tcx> { // This logic is similar to `AbiMap::canonize_abi` (in rustc_target/src/spec/abi_map.rs) but // we need more detail than those adjustments, and we can't support all ABIs that are // generally supported. - let calling_convention = if self.tcx.sess.target.arch == "x86" { + let calling_convention = if self.tcx.sess.target.arch == Arch::X86 { match abi { ExternAbi::C { .. } | ExternAbi::Cdecl { .. } => DllCallingConvention::C, ExternAbi::Stdcall { .. } => { diff --git a/compiler/rustc_middle/src/ty/context.rs b/compiler/rustc_middle/src/ty/context.rs index 60effa13406be..a00eaef20c083 100644 --- a/compiler/rustc_middle/src/ty/context.rs +++ b/compiler/rustc_middle/src/ty/context.rs @@ -2388,7 +2388,7 @@ impl<'tcx> TyCtxt<'tcx> { /// Determines whether identifiers in the assembly have strict naming rules. /// Currently, only NVPTX* targets need it. pub fn has_strict_asm_symbol_naming(self) -> bool { - self.sess.target.arch.contains("nvptx") + self.sess.target.llvm_target.starts_with("nvptx") } /// Returns `&'static core::panic::Location<'static>`. diff --git a/compiler/rustc_session/src/config/cfg.rs b/compiler/rustc_session/src/config/cfg.rs index a72f6201dcea2..9cb25ad11aacb 100644 --- a/compiler/rustc_session/src/config/cfg.rs +++ b/compiler/rustc_session/src/config/cfg.rs @@ -240,7 +240,7 @@ pub(crate) fn default_configuration(sess: &Session) -> Cfg { } ins_str!(sym::target_abi, &sess.target.abi); - ins_str!(sym::target_arch, &sess.target.arch); + ins_str!(sym::target_arch, sess.target.arch.desc()); ins_str!(sym::target_endian, sess.target.endian.as_str()); ins_str!(sym::target_env, &sess.target.env); @@ -448,7 +448,7 @@ impl CheckCfg { for target in Target::builtins().chain(iter::once(current_target.clone())) { values_target_abi.insert(Symbol::intern(&target.options.abi)); - values_target_arch.insert(Symbol::intern(&target.arch)); + values_target_arch.insert(Symbol::intern(target.arch.desc())); values_target_endian.insert(Symbol::intern(target.options.endian.as_str())); values_target_env.insert(Symbol::intern(&target.options.env)); values_target_family.extend( diff --git a/compiler/rustc_session/src/session.rs b/compiler/rustc_session/src/session.rs index 522faf1db9ff1..63d64b410950a 100644 --- a/compiler/rustc_session/src/session.rs +++ b/compiler/rustc_session/src/session.rs @@ -32,7 +32,7 @@ use rustc_span::source_map::{FilePathMapping, SourceMap}; use rustc_span::{FileNameDisplayPreference, RealFileName, Span, Symbol}; use rustc_target::asm::InlineAsmArch; use rustc_target::spec::{ - CodeModel, DebuginfoKind, PanicStrategy, RelocModel, RelroLevel, SanitizerSet, + Arch, CodeModel, DebuginfoKind, PanicStrategy, RelocModel, RelroLevel, SanitizerSet, SmallDataThresholdSupport, SplitDebuginfo, StackProtector, SymbolVisibility, Target, TargetTuple, TlsModel, apple, }; @@ -1112,7 +1112,7 @@ pub fn build_session( _ => CtfeBacktrace::Disabled, }); - let asm_arch = if target.allow_asm { InlineAsmArch::from_str(&target.arch).ok() } else { None }; + let asm_arch = if target.allow_asm { InlineAsmArch::from_arch(target.arch) } else { None }; let target_filesearch = filesearch::FileSearch::new(&sopts.search_paths, &target_tlib_path, &target); let host_filesearch = filesearch::FileSearch::new(&sopts.search_paths, &host_tlib_path, &host); @@ -1202,7 +1202,7 @@ fn validate_commandline_args_with_session_available(sess: &Session) { let mut unsupported_sanitizers = sess.opts.unstable_opts.sanitizer - supported_sanitizers; // Niche: if `fixed-x18`, or effectively switching on `reserved-x18` flag, is enabled // we should allow Shadow Call Stack sanitizer. - if sess.opts.unstable_opts.fixed_x18 && sess.target.arch == "aarch64" { + if sess.opts.unstable_opts.fixed_x18 && sess.target.arch == Arch::AArch64 { unsupported_sanitizers -= SanitizerSet::SHADOWCALLSTACK; } match unsupported_sanitizers.into_iter().count() { @@ -1313,7 +1313,7 @@ fn validate_commandline_args_with_session_available(sess: &Session) { } } - if sess.opts.unstable_opts.branch_protection.is_some() && sess.target.arch != "aarch64" { + if sess.opts.unstable_opts.branch_protection.is_some() && sess.target.arch != Arch::AArch64 { sess.dcx().emit_err(errors::BranchProtectionRequiresAArch64); } @@ -1357,13 +1357,13 @@ fn validate_commandline_args_with_session_available(sess: &Session) { } if sess.opts.unstable_opts.function_return != FunctionReturn::default() { - if sess.target.arch != "x86" && sess.target.arch != "x86_64" { + if !matches!(sess.target.arch, Arch::X86 | Arch::X86_64) { sess.dcx().emit_err(errors::FunctionReturnRequiresX86OrX8664); } } if sess.opts.unstable_opts.indirect_branch_cs_prefix { - if sess.target.arch != "x86" && sess.target.arch != "x86_64" { + if !matches!(sess.target.arch, Arch::X86 | Arch::X86_64) { sess.dcx().emit_err(errors::IndirectBranchCsPrefixRequiresX86OrX8664); } } @@ -1372,12 +1372,12 @@ fn validate_commandline_args_with_session_available(sess: &Session) { if regparm > 3 { sess.dcx().emit_err(errors::UnsupportedRegparm { regparm }); } - if sess.target.arch != "x86" { + if sess.target.arch != Arch::X86 { sess.dcx().emit_err(errors::UnsupportedRegparmArch); } } if sess.opts.unstable_opts.reg_struct_return { - if sess.target.arch != "x86" { + if sess.target.arch != Arch::X86 { sess.dcx().emit_err(errors::UnsupportedRegStructReturnArch); } } @@ -1399,7 +1399,7 @@ fn validate_commandline_args_with_session_available(sess: &Session) { } if sess.opts.cg.soft_float { - if sess.target.arch == "arm" { + if sess.target.arch == Arch::Arm { sess.dcx().emit_warn(errors::SoftFloatDeprecated); } else { // All `use_softfp` does is the equivalent of `-mfloat-abi` in GCC/clang, which only exists on ARM targets. diff --git a/compiler/rustc_target/src/asm/mod.rs b/compiler/rustc_target/src/asm/mod.rs index 5d9e39d4fc20f..e5c140a848c34 100644 --- a/compiler/rustc_target/src/asm/mod.rs +++ b/compiler/rustc_target/src/asm/mod.rs @@ -1,12 +1,11 @@ use std::fmt; -use std::str::FromStr; use rustc_abi::Size; use rustc_data_structures::fx::{FxHashMap, FxIndexSet}; use rustc_macros::{Decodable, Encodable, HashStable_Generic}; use rustc_span::Symbol; -use crate::spec::{RelocModel, Target}; +use crate::spec::{Arch, RelocModel, Target}; pub struct ModifierInfo { pub modifier: char, @@ -245,38 +244,36 @@ pub enum InlineAsmArch { CSKY, } -impl FromStr for InlineAsmArch { - type Err = (); - - fn from_str(s: &str) -> Result { - match s { - "x86" => Ok(Self::X86), - "x86_64" => Ok(Self::X86_64), - "arm" => Ok(Self::Arm), - "aarch64" => Ok(Self::AArch64), - "arm64ec" => Ok(Self::Arm64EC), - "riscv32" => Ok(Self::RiscV32), - "riscv64" => Ok(Self::RiscV64), - "nvptx64" => Ok(Self::Nvptx64), - "powerpc" => Ok(Self::PowerPC), - "powerpc64" => Ok(Self::PowerPC64), - "hexagon" => Ok(Self::Hexagon), - "loongarch32" => Ok(Self::LoongArch32), - "loongarch64" => Ok(Self::LoongArch64), - "mips" | "mips32r6" => Ok(Self::Mips), - "mips64" | "mips64r6" => Ok(Self::Mips64), - "s390x" => Ok(Self::S390x), - "sparc" => Ok(Self::Sparc), - "sparc64" => Ok(Self::Sparc64), - "spirv" => Ok(Self::SpirV), - "wasm32" => Ok(Self::Wasm32), - "wasm64" => Ok(Self::Wasm64), - "bpf" => Ok(Self::Bpf), - "avr" => Ok(Self::Avr), - "msp430" => Ok(Self::Msp430), - "m68k" => Ok(Self::M68k), - "csky" => Ok(Self::CSKY), - _ => Err(()), +impl InlineAsmArch { + pub fn from_arch(arch: Arch) -> Option { + match arch { + Arch::X86 => Some(Self::X86), + Arch::X86_64 => Some(Self::X86_64), + Arch::Arm => Some(Self::Arm), + Arch::Arm64EC => Some(Self::Arm64EC), + Arch::AArch64 => Some(Self::AArch64), + Arch::RiscV32 => Some(Self::RiscV32), + Arch::RiscV64 => Some(Self::RiscV64), + Arch::Nvptx64 => Some(Self::Nvptx64), + Arch::Hexagon => Some(Self::Hexagon), + Arch::LoongArch32 => Some(Self::LoongArch32), + Arch::LoongArch64 => Some(Self::LoongArch64), + Arch::Mips | Arch::Mips32r6 => Some(Self::Mips), + Arch::Mips64 | Arch::Mips64r6 => Some(Self::Mips64), + Arch::PowerPC => Some(Self::PowerPC), + Arch::PowerPC64 | Arch::PowerPC64LE => Some(Self::PowerPC64), + Arch::S390x => Some(Self::S390x), + Arch::Sparc => Some(Self::Sparc), + Arch::Sparc64 => Some(Self::Sparc64), + Arch::SpirV => Some(Self::SpirV), + Arch::Wasm32 => Some(Self::Wasm32), + Arch::Wasm64 => Some(Self::Wasm64), + Arch::Bpf => Some(Self::Bpf), + Arch::Avr => Some(Self::Avr), + Arch::Msp430 => Some(Self::Msp430), + Arch::M68k => Some(Self::M68k), + Arch::CSky => Some(Self::CSKY), + Arch::AmdGpu | Arch::Xtensa => None, } } } diff --git a/compiler/rustc_target/src/callconv/mod.rs b/compiler/rustc_target/src/callconv/mod.rs index 5411e8f8176b0..ef55bc45a7742 100644 --- a/compiler/rustc_target/src/callconv/mod.rs +++ b/compiler/rustc_target/src/callconv/mod.rs @@ -7,7 +7,7 @@ use rustc_abi::{ use rustc_macros::HashStable_Generic; pub use crate::spec::AbiMap; -use crate::spec::{HasTargetSpec, HasX86AbiOpt}; +use crate::spec::{Arch, HasTargetSpec, HasX86AbiOpt}; mod aarch64; mod amdgpu; @@ -633,8 +633,8 @@ impl<'a, Ty> FnAbi<'a, Ty> { } let spec = cx.target_spec(); - match &spec.arch[..] { - "x86" => { + match spec.arch { + Arch::X86 => { let (flavor, regparm) = match abi { ExternAbi::Fastcall { .. } | ExternAbi::Vectorcall { .. } => { (x86::Flavor::FastcallOrVectorcall, None) @@ -652,7 +652,7 @@ impl<'a, Ty> FnAbi<'a, Ty> { x86::compute_abi_info(cx, self, opts); } } - "x86_64" => match abi { + Arch::X86_64 => match abi { ExternAbi::SysV64 { .. } => x86_64::compute_abi_info(cx, self), ExternAbi::Win64 { .. } | ExternAbi::Vectorcall { .. } => { x86_win64::compute_abi_info(cx, self) @@ -665,7 +665,7 @@ impl<'a, Ty> FnAbi<'a, Ty> { } } }, - "aarch64" | "arm64ec" => { + Arch::AArch64 | Arch::Arm64EC => { let kind = if cx.target_spec().is_like_darwin { aarch64::AbiKind::DarwinPCS } else if cx.target_spec().is_like_windows { @@ -675,33 +675,35 @@ impl<'a, Ty> FnAbi<'a, Ty> { }; aarch64::compute_abi_info(cx, self, kind) } - "amdgpu" => amdgpu::compute_abi_info(cx, self), - "arm" => arm::compute_abi_info(cx, self), - "avr" => avr::compute_abi_info(cx, self), - "loongarch32" | "loongarch64" => loongarch::compute_abi_info(cx, self), - "m68k" => m68k::compute_abi_info(cx, self), - "csky" => csky::compute_abi_info(cx, self), - "mips" | "mips32r6" => mips::compute_abi_info(cx, self), - "mips64" | "mips64r6" => mips64::compute_abi_info(cx, self), - "powerpc" => powerpc::compute_abi_info(cx, self), - "powerpc64" => powerpc64::compute_abi_info(cx, self), - "s390x" => s390x::compute_abi_info(cx, self), - "msp430" => msp430::compute_abi_info(cx, self), - "sparc" => sparc::compute_abi_info(cx, self), - "sparc64" => sparc64::compute_abi_info(cx, self), - "nvptx64" => { + Arch::AmdGpu => amdgpu::compute_abi_info(cx, self), + Arch::Arm => arm::compute_abi_info(cx, self), + Arch::Avr => avr::compute_abi_info(cx, self), + Arch::LoongArch32 | Arch::LoongArch64 => loongarch::compute_abi_info(cx, self), + Arch::M68k => m68k::compute_abi_info(cx, self), + Arch::CSky => csky::compute_abi_info(cx, self), + Arch::Mips | Arch::Mips32r6 => mips::compute_abi_info(cx, self), + Arch::Mips64 | Arch::Mips64r6 => mips64::compute_abi_info(cx, self), + Arch::PowerPC => powerpc::compute_abi_info(cx, self), + Arch::PowerPC64 => powerpc64::compute_abi_info(cx, self), + Arch::S390x => s390x::compute_abi_info(cx, self), + Arch::Msp430 => msp430::compute_abi_info(cx, self), + Arch::Sparc => sparc::compute_abi_info(cx, self), + Arch::Sparc64 => sparc64::compute_abi_info(cx, self), + Arch::Nvptx64 => { if abi == ExternAbi::PtxKernel || abi == ExternAbi::GpuKernel { nvptx64::compute_ptx_kernel_abi_info(cx, self) } else { nvptx64::compute_abi_info(cx, self) } } - "hexagon" => hexagon::compute_abi_info(cx, self), - "xtensa" => xtensa::compute_abi_info(cx, self), - "riscv32" | "riscv64" => riscv::compute_abi_info(cx, self), - "wasm32" | "wasm64" => wasm::compute_abi_info(cx, self), - "bpf" => bpf::compute_abi_info(cx, self), - arch => panic!("no lowering implemented for {arch}"), + Arch::Hexagon => hexagon::compute_abi_info(cx, self), + Arch::Xtensa => xtensa::compute_abi_info(cx, self), + Arch::RiscV32 | Arch::RiscV64 => riscv::compute_abi_info(cx, self), + Arch::Wasm32 | Arch::Wasm64 => wasm::compute_abi_info(cx, self), + Arch::Bpf => bpf::compute_abi_info(cx, self), + arch @ (Arch::PowerPC64LE | Arch::SpirV) => { + panic!("no lowering implemented for {arch}") + } } } @@ -711,12 +713,12 @@ impl<'a, Ty> FnAbi<'a, Ty> { C: HasDataLayout + HasTargetSpec, { let spec = cx.target_spec(); - match &*spec.arch { - "x86" => x86::compute_rust_abi_info(cx, self), - "riscv32" | "riscv64" => riscv::compute_rust_abi_info(cx, self), - "loongarch32" | "loongarch64" => loongarch::compute_rust_abi_info(cx, self), - "aarch64" => aarch64::compute_rust_abi_info(cx, self), - "bpf" => bpf::compute_rust_abi_info(self), + match spec.arch { + Arch::X86 => x86::compute_rust_abi_info(cx, self), + Arch::RiscV32 | Arch::RiscV64 => riscv::compute_rust_abi_info(cx, self), + Arch::LoongArch32 | Arch::LoongArch64 => loongarch::compute_rust_abi_info(cx, self), + Arch::AArch64 => aarch64::compute_rust_abi_info(cx, self), + Arch::Bpf => bpf::compute_rust_abi_info(self), _ => {} }; diff --git a/compiler/rustc_target/src/spec/abi_map.rs b/compiler/rustc_target/src/spec/abi_map.rs index 5370903d0d6ae..8126227d80e48 100644 --- a/compiler/rustc_target/src/spec/abi_map.rs +++ b/compiler/rustc_target/src/spec/abi_map.rs @@ -1,6 +1,6 @@ use rustc_abi::{ArmCall, CanonAbi, ExternAbi, InterruptKind, X86Call}; -use crate::spec::Target; +use crate::spec::{Arch, Target}; /// Mapping for ExternAbi to CanonAbi according to a Target /// @@ -47,17 +47,20 @@ impl AbiMap { /// create an AbiMap according to arbitrary fields on the [Target] pub fn from_target(target: &Target) -> Self { // the purpose of this little exercise is to force listing what affects these mappings - let arch = match &*target.arch { - "aarch64" => ArchKind::Aarch64, - "amdgpu" => ArchKind::Amdgpu, - "arm" if target.llvm_target.starts_with("thumbv8m") => ArchKind::Arm(ArmVer::ThumbV8M), - "arm" => ArchKind::Arm(ArmVer::Other), - "avr" => ArchKind::Avr, - "msp430" => ArchKind::Msp430, - "nvptx64" => ArchKind::Nvptx, - "riscv32" | "riscv64" => ArchKind::Riscv, - "x86" => ArchKind::X86, - "x86_64" => ArchKind::X86_64, + let arch = match target.arch { + Arch::AArch64 => ArchKind::Aarch64, + Arch::AmdGpu => ArchKind::Amdgpu, + Arch::Arm => ArchKind::Arm(if target.llvm_target.starts_with("thumbv8m") { + ArmVer::ThumbV8M + } else { + ArmVer::Other + }), + Arch::Avr => ArchKind::Avr, + Arch::Msp430 => ArchKind::Msp430, + Arch::Nvptx64 => ArchKind::Nvptx, + Arch::RiscV32 | Arch::RiscV64 => ArchKind::Riscv, + Arch::X86 => ArchKind::X86, + Arch::X86_64 => ArchKind::X86_64, _ => ArchKind::Other, }; diff --git a/compiler/rustc_target/src/spec/base/apple/mod.rs b/compiler/rustc_target/src/spec/base/apple/mod.rs index 8f0b9a4517f92..cf147e48c501e 100644 --- a/compiler/rustc_target/src/spec/base/apple/mod.rs +++ b/compiler/rustc_target/src/spec/base/apple/mod.rs @@ -40,13 +40,13 @@ impl Arch { } } - pub(crate) fn target_arch(self) -> Cow<'static, str> { - Cow::Borrowed(match self { - Self::Armv7k | Self::Armv7s => "arm", - Self::Arm64 | Self::Arm64e | Self::Arm64_32 => "aarch64", - Self::I386 | Self::I686 => "x86", - Self::X86_64 | Self::X86_64h => "x86_64", - }) + pub(crate) fn target_arch(self) -> crate::spec::Arch { + match self { + Self::Armv7k | Self::Armv7s => crate::spec::Arch::Arm, + Self::Arm64 | Self::Arm64e | Self::Arm64_32 => crate::spec::Arch::AArch64, + Self::I386 | Self::I686 => crate::spec::Arch::X86, + Self::X86_64 | Self::X86_64h => crate::spec::Arch::X86_64, + } } fn target_cpu(self, env: TargetEnv) -> &'static str { @@ -109,7 +109,7 @@ pub(crate) fn base( os: &'static str, arch: Arch, env: TargetEnv, -) -> (TargetOptions, StaticCow, StaticCow) { +) -> (TargetOptions, StaticCow, crate::spec::Arch) { let mut opts = TargetOptions { llvm_floatabi: Some(FloatAbi::Hard), os: os.into(), @@ -311,18 +311,22 @@ impl OSVersion { /// This matches what LLVM does, see in part: /// pub fn minimum_deployment_target(target: &Target) -> Self { - let (major, minor, patch) = match (&*target.os, &*target.arch, &*target.env) { - ("macos", "aarch64", _) => (11, 0, 0), - ("ios", "aarch64", "macabi") => (14, 0, 0), - ("ios", "aarch64", "sim") => (14, 0, 0), + let (major, minor, patch) = match (&*target.os, target.arch, &*target.env) { + ("macos", crate::spec::Arch::AArch64, _) => (11, 0, 0), + ("ios", crate::spec::Arch::AArch64, "macabi") => (14, 0, 0), + ("ios", crate::spec::Arch::AArch64, "sim") => (14, 0, 0), ("ios", _, _) if target.llvm_target.starts_with("arm64e") => (14, 0, 0), // Mac Catalyst defaults to 13.1 in Clang. ("ios", _, "macabi") => (13, 1, 0), - ("tvos", "aarch64", "sim") => (14, 0, 0), - ("watchos", "aarch64", "sim") => (7, 0, 0), + ("tvos", crate::spec::Arch::AArch64, "sim") => (14, 0, 0), + ("watchos", crate::spec::Arch::AArch64, "sim") => (7, 0, 0), // True Aarch64 on watchOS (instead of their Aarch64 Ilp32 called `arm64_32`) has been // available since Xcode 14, but it's only actually used more recently in watchOS 26. - ("watchos", "aarch64", "") if !target.llvm_target.starts_with("arm64_32") => (26, 0, 0), + ("watchos", crate::spec::Arch::AArch64, "") + if !target.llvm_target.starts_with("arm64_32") => + { + (26, 0, 0) + } (os, _, _) => return Self::os_minimum_deployment_target(os), }; Self { major, minor, patch } diff --git a/compiler/rustc_target/src/spec/base/nto_qnx.rs b/compiler/rustc_target/src/spec/base/nto_qnx.rs index 6498742917545..119c5ec98f959 100644 --- a/compiler/rustc_target/src/spec/base/nto_qnx.rs +++ b/compiler/rustc_target/src/spec/base/nto_qnx.rs @@ -41,7 +41,7 @@ pub(crate) fn aarch64() -> Target { // n32:64 = 32 and 64 are native integer widths; Elements of this set are considered to support most general arithmetic operations efficiently. // S128 = 128 bits are the natural alignment of the stack in bits. data_layout: "e-m:e-p270:32:32-p271:32:32-p272:64:64-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128-Fn32".into(), - arch: "aarch64".into(), + arch: crate::spec::Arch::AArch64, options: TargetOptions { features: "+v8a".into(), max_atomic_width: Some(128), @@ -57,7 +57,7 @@ pub(crate) fn x86_64() -> Target { pointer_width: 64, data_layout: "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128".into(), - arch: "x86_64".into(), + arch: crate::spec::Arch::X86_64, options: TargetOptions { cpu: "x86-64".into(), plt_by_default: false, diff --git a/compiler/rustc_target/src/spec/json.rs b/compiler/rustc_target/src/spec/json.rs index f236be92b3b60..c25628c3939db 100644 --- a/compiler/rustc_target/src/spec/json.rs +++ b/compiler/rustc_target/src/spec/json.rs @@ -5,7 +5,7 @@ use rustc_abi::{Align, AlignFromBytesError}; use super::crt_objects::CrtObjects; use super::{ - BinaryFormat, CodeModel, DebuginfoKind, FloatAbi, FramePointer, LinkArgsCli, + Arch, BinaryFormat, CodeModel, DebuginfoKind, FloatAbi, FramePointer, LinkArgsCli, LinkSelfContainedComponents, LinkSelfContainedDefault, LinkerFlavorCli, LldFlavor, MergeFunctions, PanicStrategy, RelocModel, RelroLevel, RustcAbi, SanitizerSet, SmallDataThresholdSupport, SplitDebuginfo, StackProbeType, StaticCow, SymbolVisibility, Target, @@ -486,7 +486,7 @@ struct TargetSpecJson { llvm_target: StaticCow, target_pointer_width: u16, data_layout: StaticCow, - arch: StaticCow, + arch: Arch, metadata: Option, diff --git a/compiler/rustc_target/src/spec/mod.rs b/compiler/rustc_target/src/spec/mod.rs index b49e7fc9cff66..892be1e18ca2e 100644 --- a/compiler/rustc_target/src/spec/mod.rs +++ b/compiler/rustc_target/src/spec/mod.rs @@ -1847,6 +1847,44 @@ enum TargetKind { Builtin, } +crate::target_spec_enum! { + pub enum Arch { + AArch64 = "aarch64", + AmdGpu = "amdgpu", + Arm = "arm", + Arm64EC = "arm64ec", + Avr = "avr", + Bpf = "bpf", + CSky = "csky", + Hexagon = "hexagon", + LoongArch32 = "loongarch32", + LoongArch64 = "loongarch64", + M68k = "m68k", + Mips = "mips", + Mips32r6 = "mips32r6", + Mips64 = "mips64", + Mips64r6 = "mips64r6", + Msp430 = "msp430", + Nvptx64 = "nvptx64", + PowerPC = "powerpc", + PowerPC64 = "powerpc64", + PowerPC64LE = "powerpc64le", + RiscV32 = "riscv32", + RiscV64 = "riscv64", + S390x = "s390x", + Sparc = "sparc", + Sparc64 = "sparc64", + SpirV = "spirv", + Wasm32 = "wasm32", + Wasm64 = "wasm64", + X86 = "x86", + X86_64 = "x86_64", + Xtensa = "xtensa", + } + + parse_error_type = "architecture"; +} + /// Everything `rustc` knows about how to compile for a specific target. /// /// Every field here must be specified, and has no default value. @@ -1866,7 +1904,7 @@ pub struct Target { pub pointer_width: u16, /// Architecture to use for ABI considerations. Valid options include: "x86", /// "x86_64", "arm", "aarch64", "mips", "powerpc", "powerpc64", and others. - pub arch: StaticCow, + pub arch: Arch, /// [Data layout](https://llvm.org/docs/LangRef.html#data-layout) to pass to LLVM. pub data_layout: StaticCow, /// Optional settings with defaults. @@ -2672,7 +2710,7 @@ impl Target { ); check_eq!( self.is_like_wasm, - self.arch == "wasm32" || self.arch == "wasm64", + matches!(self.arch, Arch::Wasm32 | Arch::Wasm64), "`is_like_wasm` must be set if and only if `arch` is `wasm32` or `wasm64`" ); if self.is_like_msvc { @@ -2704,12 +2742,12 @@ impl Target { "`linker_flavor` must be `em-cc` if and only if `os` is `emscripten`" ); check_eq!( - self.arch == "bpf", + self.arch == Arch::Bpf, matches!(self.linker_flavor, LinkerFlavor::Bpf), "`linker_flavor` must be `bpf` if and only if `arch` is `bpf`" ); check_eq!( - self.arch == "nvptx64", + self.arch == Arch::Nvptx64, matches!(self.linker_flavor, LinkerFlavor::Ptx), "`linker_flavor` must be `ptc` if and only if `arch` is `nvptx64`" ); @@ -2723,7 +2761,7 @@ impl Target { ] { for (&flavor, flavor_args) in args { check!( - !flavor_args.is_empty() || self.arch == "avr", + !flavor_args.is_empty() || self.arch == Arch::Avr, "linker flavor args must not be empty" ); // Check that flavors mentioned in link args are compatible with the default flavor. @@ -2846,10 +2884,7 @@ impl Target { // hexagon: when targeting QuRT, that OS can load dynamic libraries. // wasm{32,64}: dynamic linking is inherent in the definition of the VM. if self.os == "none" - && (self.arch != "bpf" - && self.arch != "hexagon" - && self.arch != "wasm32" - && self.arch != "wasm64") + && !matches!(self.arch, Arch::Bpf | Arch::Hexagon | Arch::Wasm32 | Arch::Wasm64) { check!( !self.dynamic_linking, @@ -2912,8 +2947,8 @@ impl Target { // Check that RISC-V targets always specify which ABI they use, // and that ARM targets specify their float ABI. - match &*self.arch { - "riscv32" => { + match self.arch { + Arch::RiscV32 => { check_matches!( &*self.llvm_abiname, "ilp32" | "ilp32f" | "ilp32d" | "ilp32e", @@ -2921,7 +2956,7 @@ impl Target { self.llvm_abiname, ); } - "riscv64" => { + Arch::RiscV64 => { // Note that the `lp64e` is still unstable as it's not (yet) part of the ELF psABI. check_matches!( &*self.llvm_abiname, @@ -2930,7 +2965,7 @@ impl Target { self.llvm_abiname, ); } - "arm" => { + Arch::Arm => { check!( self.llvm_floatabi.is_some(), "ARM targets must set `llvm-floatabi` to `hard` or `soft`", @@ -2943,13 +2978,13 @@ impl Target { if let Some(rust_abi) = self.rustc_abi { match rust_abi { RustcAbi::X86Sse2 => check_matches!( - &*self.arch, - "x86", + self.arch, + Arch::X86, "`x86-sse2` ABI is only valid for x86-32 targets" ), RustcAbi::X86Softfloat => check_matches!( - &*self.arch, - "x86" | "x86_64", + self.arch, + Arch::X86 | Arch::X86_64, "`x86-softfloat` ABI is only valid for x86 targets" ), } @@ -3116,15 +3151,15 @@ impl Target { // Avoid having to duplicate the small data support in every // target file by supporting a default value for each // architecture. - SmallDataThresholdSupport::DefaultForArch => match self.arch.as_ref() { - "mips" | "mips64" | "mips32r6" => { + SmallDataThresholdSupport::DefaultForArch => match self.arch { + Arch::Mips | Arch::Mips64 | Arch::Mips32r6 => { SmallDataThresholdSupport::LlvmArg("mips-ssection-threshold".into()) } - "hexagon" => { + Arch::Hexagon => { SmallDataThresholdSupport::LlvmArg("hexagon-small-data-threshold".into()) } - "m68k" => SmallDataThresholdSupport::LlvmArg("m68k-ssection-threshold".into()), - "riscv32" | "riscv64" => { + Arch::M68k => SmallDataThresholdSupport::LlvmArg("m68k-ssection-threshold".into()), + Arch::RiscV32 | Arch::RiscV64 => { SmallDataThresholdSupport::LlvmModuleFlag("SmallDataLimit".into()) } _ => SmallDataThresholdSupport::None, @@ -3138,9 +3173,9 @@ impl Target { unstable_target_features: &FxIndexSet, ) -> Option<(object::Architecture, Option)> { use object::Architecture; - Some(match self.arch.as_ref() { - "arm" => (Architecture::Arm, None), - "aarch64" => ( + Some(match self.arch { + Arch::Arm => (Architecture::Arm, None), + Arch::AArch64 => ( if self.pointer_width == 32 { Architecture::Aarch64_Ilp32 } else { @@ -3148,11 +3183,11 @@ impl Target { }, None, ), - "x86" => (Architecture::I386, None), - "s390x" => (Architecture::S390x, None), - "m68k" => (Architecture::M68k, None), - "mips" | "mips32r6" => (Architecture::Mips, None), - "mips64" | "mips64r6" => ( + Arch::X86 => (Architecture::I386, None), + Arch::S390x => (Architecture::S390x, None), + Arch::M68k => (Architecture::M68k, None), + Arch::Mips | Arch::Mips32r6 => (Architecture::Mips, None), + Arch::Mips64 | Arch::Mips64r6 => ( // While there are currently no builtin targets // using the N32 ABI, it is possible to specify // it using a custom target specification. N32 @@ -3165,7 +3200,7 @@ impl Target { }, None, ), - "x86_64" => ( + Arch::X86_64 => ( if self.pointer_width == 32 { Architecture::X86_64_X32 } else { @@ -3173,11 +3208,11 @@ impl Target { }, None, ), - "powerpc" => (Architecture::PowerPc, None), - "powerpc64" => (Architecture::PowerPc64, None), - "riscv32" => (Architecture::Riscv32, None), - "riscv64" => (Architecture::Riscv64, None), - "sparc" => { + Arch::PowerPC => (Architecture::PowerPc, None), + Arch::PowerPC64 => (Architecture::PowerPc64, None), + Arch::RiscV32 => (Architecture::Riscv32, None), + Arch::RiscV64 => (Architecture::Riscv64, None), + Arch::Sparc => { if unstable_target_features.contains(&sym::v8plus) { // Target uses V8+, aka EM_SPARC32PLUS, aka 64-bit V9 but in 32-bit mode (Architecture::Sparc32Plus, None) @@ -3186,18 +3221,22 @@ impl Target { (Architecture::Sparc, None) } } - "sparc64" => (Architecture::Sparc64, None), - "avr" => (Architecture::Avr, None), - "msp430" => (Architecture::Msp430, None), - "hexagon" => (Architecture::Hexagon, None), - "xtensa" => (Architecture::Xtensa, None), - "bpf" => (Architecture::Bpf, None), - "loongarch32" => (Architecture::LoongArch32, None), - "loongarch64" => (Architecture::LoongArch64, None), - "csky" => (Architecture::Csky, None), - "arm64ec" => (Architecture::Aarch64, Some(object::SubArchitecture::Arm64EC)), - // Unsupported architecture. - _ => return None, + Arch::Sparc64 => (Architecture::Sparc64, None), + Arch::Avr => (Architecture::Avr, None), + Arch::Msp430 => (Architecture::Msp430, None), + Arch::Hexagon => (Architecture::Hexagon, None), + Arch::Xtensa => (Architecture::Xtensa, None), + Arch::Bpf => (Architecture::Bpf, None), + Arch::LoongArch32 => (Architecture::LoongArch32, None), + Arch::LoongArch64 => (Architecture::LoongArch64, None), + Arch::CSky => (Architecture::Csky, None), + Arch::Arm64EC => (Architecture::Aarch64, Some(object::SubArchitecture::Arm64EC)), + Arch::AmdGpu + | Arch::Nvptx64 + | Arch::PowerPC64LE + | Arch::SpirV + | Arch::Wasm32 + | Arch::Wasm64 => return None, }) } @@ -3213,7 +3252,7 @@ impl Target { // FIXME(#112480) MSVC on x86-32 is unsound and fails to properly align many types with // more-than-4-byte-alignment on the stack. This makes alignments larger than 4 generally // unreliable on 32bit Windows. - if self.is_like_windows && self.arch == "x86" { + if self.is_like_windows && self.arch == Arch::X86 { Align::from_bytes(4).unwrap() } else { Align::MAX diff --git a/compiler/rustc_target/src/spec/targets/aarch64_be_unknown_hermit.rs b/compiler/rustc_target/src/spec/targets/aarch64_be_unknown_hermit.rs index cad57abc2b1e0..78ae0f55bb42e 100644 --- a/compiler/rustc_target/src/spec/targets/aarch64_be_unknown_hermit.rs +++ b/compiler/rustc_target/src/spec/targets/aarch64_be_unknown_hermit.rs @@ -1,6 +1,6 @@ use rustc_abi::Endian; -use crate::spec::{StackProbeType, Target, TargetMetadata, TargetOptions, base}; +use crate::spec::{Arch, StackProbeType, Target, TargetMetadata, TargetOptions, base}; pub(crate) fn target() -> Target { Target { @@ -12,7 +12,7 @@ pub(crate) fn target() -> Target { std: Some(true), }, pointer_width: 64, - arch: "aarch64".into(), + arch: Arch::AArch64, data_layout: "E-m:e-p270:32:32-p271:32:32-p272:64:64-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128-Fn32".into(), options: TargetOptions { features: "+v8a,+strict-align,+neon,+fp-armv8".into(), diff --git a/compiler/rustc_target/src/spec/targets/aarch64_be_unknown_linux_gnu.rs b/compiler/rustc_target/src/spec/targets/aarch64_be_unknown_linux_gnu.rs index 4b75a6e5dbf61..659bcdc3be74c 100644 --- a/compiler/rustc_target/src/spec/targets/aarch64_be_unknown_linux_gnu.rs +++ b/compiler/rustc_target/src/spec/targets/aarch64_be_unknown_linux_gnu.rs @@ -1,6 +1,8 @@ use rustc_abi::Endian; -use crate::spec::{FramePointer, StackProbeType, Target, TargetMetadata, TargetOptions, base}; +use crate::spec::{ + Arch, FramePointer, StackProbeType, Target, TargetMetadata, TargetOptions, base, +}; pub(crate) fn target() -> Target { Target { @@ -13,7 +15,7 @@ pub(crate) fn target() -> Target { }, pointer_width: 64, data_layout: "E-m:e-p270:32:32-p271:32:32-p272:64:64-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128-Fn32".into(), - arch: "aarch64".into(), + arch: Arch::AArch64, options: TargetOptions { features: "+v8a,+outline-atomics".into(), // the AAPCS64 expects use of non-leaf frame pointers per diff --git a/compiler/rustc_target/src/spec/targets/aarch64_be_unknown_linux_gnu_ilp32.rs b/compiler/rustc_target/src/spec/targets/aarch64_be_unknown_linux_gnu_ilp32.rs index 2a16d1de3b51f..63a13b8a7d11a 100644 --- a/compiler/rustc_target/src/spec/targets/aarch64_be_unknown_linux_gnu_ilp32.rs +++ b/compiler/rustc_target/src/spec/targets/aarch64_be_unknown_linux_gnu_ilp32.rs @@ -1,6 +1,8 @@ use rustc_abi::Endian; -use crate::spec::{FramePointer, StackProbeType, Target, TargetMetadata, TargetOptions, base}; +use crate::spec::{ + Arch, FramePointer, StackProbeType, Target, TargetMetadata, TargetOptions, base, +}; pub(crate) fn target() -> Target { let mut base = base::linux_gnu::opts(); @@ -16,7 +18,7 @@ pub(crate) fn target() -> Target { }, pointer_width: 32, data_layout: "E-m:e-p:32:32-p270:32:32-p271:32:32-p272:64:64-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128-Fn32".into(), - arch: "aarch64".into(), + arch: Arch::AArch64, options: TargetOptions { abi: "ilp32".into(), features: "+v8a,+outline-atomics".into(), diff --git a/compiler/rustc_target/src/spec/targets/aarch64_be_unknown_linux_musl.rs b/compiler/rustc_target/src/spec/targets/aarch64_be_unknown_linux_musl.rs index be5ac4a843baf..d3bf641a747fa 100644 --- a/compiler/rustc_target/src/spec/targets/aarch64_be_unknown_linux_musl.rs +++ b/compiler/rustc_target/src/spec/targets/aarch64_be_unknown_linux_musl.rs @@ -1,7 +1,7 @@ use rustc_abi::Endian; use crate::spec::{ - FramePointer, SanitizerSet, StackProbeType, Target, TargetMetadata, TargetOptions, base, + Arch, FramePointer, SanitizerSet, StackProbeType, Target, TargetMetadata, TargetOptions, base, }; pub(crate) fn target() -> Target { @@ -26,7 +26,7 @@ pub(crate) fn target() -> Target { }, pointer_width: 64, data_layout: "E-m:e-p270:32:32-p271:32:32-p272:64:64-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128-Fn32".into(), - arch: "aarch64".into(), + arch: Arch::AArch64, options: TargetOptions { // the AAPCS64 expects use of non-leaf frame pointers per // https://github.com/ARM-software/abi-aa/blob/4492d1570eb70c8fd146623e0db65b2d241f12e7/aapcs64/aapcs64.rst#the-frame-pointer diff --git a/compiler/rustc_target/src/spec/targets/aarch64_be_unknown_netbsd.rs b/compiler/rustc_target/src/spec/targets/aarch64_be_unknown_netbsd.rs index 97742403c78ff..1d77669be6808 100644 --- a/compiler/rustc_target/src/spec/targets/aarch64_be_unknown_netbsd.rs +++ b/compiler/rustc_target/src/spec/targets/aarch64_be_unknown_netbsd.rs @@ -1,6 +1,6 @@ use rustc_abi::Endian; -use crate::spec::{StackProbeType, Target, TargetMetadata, TargetOptions, base}; +use crate::spec::{Arch, StackProbeType, Target, TargetMetadata, TargetOptions, base}; pub(crate) fn target() -> Target { Target { @@ -13,7 +13,7 @@ pub(crate) fn target() -> Target { }, pointer_width: 64, data_layout: "E-m:e-p270:32:32-p271:32:32-p272:64:64-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128-Fn32".into(), - arch: "aarch64".into(), + arch: Arch::AArch64, options: TargetOptions { mcount: "__mcount".into(), max_atomic_width: Some(128), diff --git a/compiler/rustc_target/src/spec/targets/aarch64_be_unknown_none_softfloat.rs b/compiler/rustc_target/src/spec/targets/aarch64_be_unknown_none_softfloat.rs index 7f918e8508094..8ba909a796012 100644 --- a/compiler/rustc_target/src/spec/targets/aarch64_be_unknown_none_softfloat.rs +++ b/compiler/rustc_target/src/spec/targets/aarch64_be_unknown_none_softfloat.rs @@ -8,7 +8,7 @@ use rustc_abi::Endian; use crate::spec::{ - Cc, LinkerFlavor, Lld, PanicStrategy, RelocModel, SanitizerSet, StackProbeType, Target, + Arch, Cc, LinkerFlavor, Lld, PanicStrategy, RelocModel, SanitizerSet, StackProbeType, Target, TargetMetadata, TargetOptions, }; @@ -37,7 +37,7 @@ pub(crate) fn target() -> Target { }, pointer_width: 64, data_layout: "E-m:e-p270:32:32-p271:32:32-p272:64:64-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128-Fn32".into(), - arch: "aarch64".into(), + arch: Arch::AArch64, options: opts, } } diff --git a/compiler/rustc_target/src/spec/targets/aarch64_kmc_solid_asp3.rs b/compiler/rustc_target/src/spec/targets/aarch64_kmc_solid_asp3.rs index f58aa1ac043ca..d6b0e09195120 100644 --- a/compiler/rustc_target/src/spec/targets/aarch64_kmc_solid_asp3.rs +++ b/compiler/rustc_target/src/spec/targets/aarch64_kmc_solid_asp3.rs @@ -1,4 +1,4 @@ -use crate::spec::{RelocModel, StackProbeType, Target, TargetMetadata, TargetOptions, base}; +use crate::spec::{Arch, RelocModel, StackProbeType, Target, TargetMetadata, TargetOptions, base}; pub(crate) fn target() -> Target { let base = base::solid::opts("asp3"); @@ -12,7 +12,7 @@ pub(crate) fn target() -> Target { }, pointer_width: 64, data_layout: "e-m:e-p270:32:32-p271:32:32-p272:64:64-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128-Fn32".into(), - arch: "aarch64".into(), + arch: Arch::AArch64, options: TargetOptions { linker: Some("aarch64-kmc-elf-gcc".into()), features: "+v8a,+neon,+fp-armv8".into(), diff --git a/compiler/rustc_target/src/spec/targets/aarch64_linux_android.rs b/compiler/rustc_target/src/spec/targets/aarch64_linux_android.rs index d8651f305fe94..2bee1cf70b45d 100644 --- a/compiler/rustc_target/src/spec/targets/aarch64_linux_android.rs +++ b/compiler/rustc_target/src/spec/targets/aarch64_linux_android.rs @@ -1,5 +1,5 @@ use crate::spec::{ - FramePointer, SanitizerSet, StackProbeType, Target, TargetMetadata, TargetOptions, base, + Arch, FramePointer, SanitizerSet, StackProbeType, Target, TargetMetadata, TargetOptions, base, }; // See https://developer.android.com/ndk/guides/abis.html#arm64-v8a @@ -16,7 +16,7 @@ pub(crate) fn target() -> Target { }, pointer_width: 64, data_layout: "e-m:e-p270:32:32-p271:32:32-p272:64:64-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128-Fn32".into(), - arch: "aarch64".into(), + arch: Arch::AArch64, options: TargetOptions { max_atomic_width: Some(128), // As documented in https://developer.android.com/ndk/guides/cpu-features.html diff --git a/compiler/rustc_target/src/spec/targets/aarch64_nintendo_switch_freestanding.rs b/compiler/rustc_target/src/spec/targets/aarch64_nintendo_switch_freestanding.rs index 61e4cad3fa202..eb8144dd44e2e 100644 --- a/compiler/rustc_target/src/spec/targets/aarch64_nintendo_switch_freestanding.rs +++ b/compiler/rustc_target/src/spec/targets/aarch64_nintendo_switch_freestanding.rs @@ -1,5 +1,5 @@ use crate::spec::{ - Cc, LinkerFlavor, Lld, PanicStrategy, RelroLevel, StackProbeType, Target, TargetMetadata, + Arch, Cc, LinkerFlavor, Lld, PanicStrategy, RelroLevel, StackProbeType, Target, TargetMetadata, TargetOptions, }; @@ -17,7 +17,7 @@ pub(crate) fn target() -> Target { }, pointer_width: 64, data_layout: "e-m:e-p270:32:32-p271:32:32-p272:64:64-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128-Fn32".into(), - arch: "aarch64".into(), + arch: Arch::AArch64, options: TargetOptions { features: "+v8a,+neon,+crypto,+crc".into(), linker_flavor: LinkerFlavor::Gnu(Cc::No, Lld::Yes), diff --git a/compiler/rustc_target/src/spec/targets/aarch64_pc_windows_gnullvm.rs b/compiler/rustc_target/src/spec/targets/aarch64_pc_windows_gnullvm.rs index eee668cc67edb..9b7db11e2f29a 100644 --- a/compiler/rustc_target/src/spec/targets/aarch64_pc_windows_gnullvm.rs +++ b/compiler/rustc_target/src/spec/targets/aarch64_pc_windows_gnullvm.rs @@ -1,4 +1,4 @@ -use crate::spec::{FramePointer, Target, TargetMetadata, base}; +use crate::spec::{Arch, FramePointer, Target, TargetMetadata, base}; pub(crate) fn target() -> Target { let mut base = base::windows_gnullvm::opts(); @@ -24,7 +24,7 @@ pub(crate) fn target() -> Target { data_layout: "e-m:w-p270:32:32-p271:32:32-p272:64:64-p:64:64-i32:32-i64:64-i128:128-n32:64-S128-Fn32" .into(), - arch: "aarch64".into(), + arch: Arch::AArch64, options: base, } } diff --git a/compiler/rustc_target/src/spec/targets/aarch64_pc_windows_msvc.rs b/compiler/rustc_target/src/spec/targets/aarch64_pc_windows_msvc.rs index cd55576ef8167..3453f1d6101b9 100644 --- a/compiler/rustc_target/src/spec/targets/aarch64_pc_windows_msvc.rs +++ b/compiler/rustc_target/src/spec/targets/aarch64_pc_windows_msvc.rs @@ -1,4 +1,4 @@ -use crate::spec::{FramePointer, Target, TargetMetadata, base}; +use crate::spec::{Arch, FramePointer, Target, TargetMetadata, base}; pub(crate) fn target() -> Target { let mut base = base::windows_msvc::opts(); @@ -23,7 +23,7 @@ pub(crate) fn target() -> Target { data_layout: "e-m:w-p270:32:32-p271:32:32-p272:64:64-p:64:64-i32:32-i64:64-i128:128-n32:64-S128-Fn32" .into(), - arch: "aarch64".into(), + arch: Arch::AArch64, options: base, } } diff --git a/compiler/rustc_target/src/spec/targets/aarch64_unknown_freebsd.rs b/compiler/rustc_target/src/spec/targets/aarch64_unknown_freebsd.rs index 7306a75aa2274..69a65e6b0f024 100644 --- a/compiler/rustc_target/src/spec/targets/aarch64_unknown_freebsd.rs +++ b/compiler/rustc_target/src/spec/targets/aarch64_unknown_freebsd.rs @@ -1,4 +1,6 @@ -use crate::spec::{SanitizerSet, StackProbeType, Target, TargetMetadata, TargetOptions, base}; +use crate::spec::{ + Arch, SanitizerSet, StackProbeType, Target, TargetMetadata, TargetOptions, base, +}; pub(crate) fn target() -> Target { Target { @@ -11,7 +13,7 @@ pub(crate) fn target() -> Target { }, pointer_width: 64, data_layout: "e-m:e-p270:32:32-p271:32:32-p272:64:64-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128-Fn32".into(), - arch: "aarch64".into(), + arch: Arch::AArch64, options: TargetOptions { features: "+v8a".into(), max_atomic_width: Some(128), diff --git a/compiler/rustc_target/src/spec/targets/aarch64_unknown_fuchsia.rs b/compiler/rustc_target/src/spec/targets/aarch64_unknown_fuchsia.rs index 8366b6d9bd824..b5907c6b1af2e 100644 --- a/compiler/rustc_target/src/spec/targets/aarch64_unknown_fuchsia.rs +++ b/compiler/rustc_target/src/spec/targets/aarch64_unknown_fuchsia.rs @@ -1,5 +1,5 @@ use crate::spec::{ - Cc, LinkerFlavor, Lld, SanitizerSet, StackProbeType, Target, TargetMetadata, base, + Arch, Cc, LinkerFlavor, Lld, SanitizerSet, StackProbeType, Target, TargetMetadata, base, }; pub(crate) fn target() -> Target { @@ -33,7 +33,7 @@ pub(crate) fn target() -> Target { }, pointer_width: 64, data_layout: "e-m:e-p270:32:32-p271:32:32-p272:64:64-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128-Fn32".into(), - arch: "aarch64".into(), + arch: Arch::AArch64, options: base, } } diff --git a/compiler/rustc_target/src/spec/targets/aarch64_unknown_helenos.rs b/compiler/rustc_target/src/spec/targets/aarch64_unknown_helenos.rs index 31b4a2111cbf6..3e168b6c15666 100644 --- a/compiler/rustc_target/src/spec/targets/aarch64_unknown_helenos.rs +++ b/compiler/rustc_target/src/spec/targets/aarch64_unknown_helenos.rs @@ -1,4 +1,4 @@ -use crate::spec::{Target, base}; +use crate::spec::{Arch, Target, base}; pub(crate) fn target() -> Target { let mut base = base::helenos::opts(); @@ -16,7 +16,7 @@ pub(crate) fn target() -> Target { }, pointer_width: 64, data_layout: "e-m:e-p270:32:32-p271:32:32-p272:64:64-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128-Fn32".into(), - arch: "aarch64".into(), + arch: Arch::AArch64, options: base, } } diff --git a/compiler/rustc_target/src/spec/targets/aarch64_unknown_hermit.rs b/compiler/rustc_target/src/spec/targets/aarch64_unknown_hermit.rs index 580a36cb2e927..2cf5c2519d562 100644 --- a/compiler/rustc_target/src/spec/targets/aarch64_unknown_hermit.rs +++ b/compiler/rustc_target/src/spec/targets/aarch64_unknown_hermit.rs @@ -1,4 +1,4 @@ -use crate::spec::{StackProbeType, Target, TargetMetadata, TargetOptions, base}; +use crate::spec::{Arch, StackProbeType, Target, TargetMetadata, TargetOptions, base}; pub(crate) fn target() -> Target { Target { @@ -10,7 +10,7 @@ pub(crate) fn target() -> Target { std: Some(true), }, pointer_width: 64, - arch: "aarch64".into(), + arch: Arch::AArch64, data_layout: "e-m:e-p270:32:32-p271:32:32-p272:64:64-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128-Fn32".into(), options: TargetOptions { features: "+v8a,+strict-align,+neon,+fp-armv8".into(), diff --git a/compiler/rustc_target/src/spec/targets/aarch64_unknown_illumos.rs b/compiler/rustc_target/src/spec/targets/aarch64_unknown_illumos.rs index 1ed4fdb465d38..e744dc78494d4 100644 --- a/compiler/rustc_target/src/spec/targets/aarch64_unknown_illumos.rs +++ b/compiler/rustc_target/src/spec/targets/aarch64_unknown_illumos.rs @@ -1,4 +1,4 @@ -use crate::spec::{Cc, LinkerFlavor, SanitizerSet, Target, TargetMetadata, base}; +use crate::spec::{Arch, Cc, LinkerFlavor, SanitizerSet, Target, TargetMetadata, base}; pub(crate) fn target() -> Target { let mut base = base::illumos::opts(); @@ -19,7 +19,7 @@ pub(crate) fn target() -> Target { }, pointer_width: 64, data_layout: "e-m:e-p270:32:32-p271:32:32-p272:64:64-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128-Fn32".into(), - arch: "aarch64".into(), + arch: Arch::AArch64, options: base, } } diff --git a/compiler/rustc_target/src/spec/targets/aarch64_unknown_linux_gnu.rs b/compiler/rustc_target/src/spec/targets/aarch64_unknown_linux_gnu.rs index 4220d74dfc890..c4b1f2c05eb10 100644 --- a/compiler/rustc_target/src/spec/targets/aarch64_unknown_linux_gnu.rs +++ b/compiler/rustc_target/src/spec/targets/aarch64_unknown_linux_gnu.rs @@ -1,5 +1,5 @@ use crate::spec::{ - FramePointer, SanitizerSet, StackProbeType, Target, TargetMetadata, TargetOptions, base, + Arch, FramePointer, SanitizerSet, StackProbeType, Target, TargetMetadata, TargetOptions, base, }; pub(crate) fn target() -> Target { @@ -13,7 +13,7 @@ pub(crate) fn target() -> Target { }, pointer_width: 64, data_layout: "e-m:e-p270:32:32-p271:32:32-p272:64:64-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128-Fn32".into(), - arch: "aarch64".into(), + arch: Arch::AArch64, options: TargetOptions { features: "+v8a,+outline-atomics".into(), // the AAPCS64 expects use of non-leaf frame pointers per diff --git a/compiler/rustc_target/src/spec/targets/aarch64_unknown_linux_gnu_ilp32.rs b/compiler/rustc_target/src/spec/targets/aarch64_unknown_linux_gnu_ilp32.rs index a22c128967736..5020d893c86be 100644 --- a/compiler/rustc_target/src/spec/targets/aarch64_unknown_linux_gnu_ilp32.rs +++ b/compiler/rustc_target/src/spec/targets/aarch64_unknown_linux_gnu_ilp32.rs @@ -1,4 +1,6 @@ -use crate::spec::{FramePointer, StackProbeType, Target, TargetMetadata, TargetOptions, base}; +use crate::spec::{ + Arch, FramePointer, StackProbeType, Target, TargetMetadata, TargetOptions, base, +}; pub(crate) fn target() -> Target { Target { @@ -11,7 +13,7 @@ pub(crate) fn target() -> Target { }, pointer_width: 32, data_layout: "e-m:e-p:32:32-p270:32:32-p271:32:32-p272:64:64-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128-Fn32".into(), - arch: "aarch64".into(), + arch: Arch::AArch64, options: TargetOptions { abi: "ilp32".into(), features: "+v8a,+outline-atomics".into(), diff --git a/compiler/rustc_target/src/spec/targets/aarch64_unknown_linux_musl.rs b/compiler/rustc_target/src/spec/targets/aarch64_unknown_linux_musl.rs index 158b38e514016..6ba5112342c3e 100644 --- a/compiler/rustc_target/src/spec/targets/aarch64_unknown_linux_musl.rs +++ b/compiler/rustc_target/src/spec/targets/aarch64_unknown_linux_musl.rs @@ -1,5 +1,5 @@ use crate::spec::{ - FramePointer, SanitizerSet, StackProbeType, Target, TargetMetadata, TargetOptions, base, + Arch, FramePointer, SanitizerSet, StackProbeType, Target, TargetMetadata, TargetOptions, base, }; pub(crate) fn target() -> Target { @@ -27,7 +27,7 @@ pub(crate) fn target() -> Target { }, pointer_width: 64, data_layout: "e-m:e-p270:32:32-p271:32:32-p272:64:64-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128-Fn32".into(), - arch: "aarch64".into(), + arch: Arch::AArch64, options: TargetOptions { // the AAPCS64 expects use of non-leaf frame pointers per // https://github.com/ARM-software/abi-aa/blob/4492d1570eb70c8fd146623e0db65b2d241f12e7/aapcs64/aapcs64.rst#the-frame-pointer diff --git a/compiler/rustc_target/src/spec/targets/aarch64_unknown_linux_ohos.rs b/compiler/rustc_target/src/spec/targets/aarch64_unknown_linux_ohos.rs index 51cdebf22db21..5f1ab6069ef00 100644 --- a/compiler/rustc_target/src/spec/targets/aarch64_unknown_linux_ohos.rs +++ b/compiler/rustc_target/src/spec/targets/aarch64_unknown_linux_ohos.rs @@ -1,5 +1,5 @@ use crate::spec::{ - FramePointer, SanitizerSet, StackProbeType, Target, TargetMetadata, TargetOptions, base, + Arch, FramePointer, SanitizerSet, StackProbeType, Target, TargetMetadata, TargetOptions, base, }; pub(crate) fn target() -> Target { @@ -16,7 +16,7 @@ pub(crate) fn target() -> Target { }, pointer_width: 64, data_layout: "e-m:e-p270:32:32-p271:32:32-p272:64:64-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128-Fn32".into(), - arch: "aarch64".into(), + arch: Arch::AArch64, options: TargetOptions { // the AAPCS64 expects use of non-leaf frame pointers per // https://github.com/ARM-software/abi-aa/blob/4492d1570eb70c8fd146623e0db65b2d241f12e7/aapcs64/aapcs64.rst#the-frame-pointer diff --git a/compiler/rustc_target/src/spec/targets/aarch64_unknown_managarm_mlibc.rs b/compiler/rustc_target/src/spec/targets/aarch64_unknown_managarm_mlibc.rs index 1fa9d7131c508..ede0f78711eba 100644 --- a/compiler/rustc_target/src/spec/targets/aarch64_unknown_managarm_mlibc.rs +++ b/compiler/rustc_target/src/spec/targets/aarch64_unknown_managarm_mlibc.rs @@ -1,4 +1,4 @@ -use crate::spec::{StackProbeType, Target, base}; +use crate::spec::{Arch, StackProbeType, Target, base}; pub(crate) fn target() -> Target { let mut base = base::managarm_mlibc::opts(); @@ -16,7 +16,7 @@ pub(crate) fn target() -> Target { }, pointer_width: 64, data_layout: "e-m:e-p270:32:32-p271:32:32-p272:64:64-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128-Fn32".into(), - arch: "aarch64".into(), + arch: Arch::AArch64, options: base } } diff --git a/compiler/rustc_target/src/spec/targets/aarch64_unknown_netbsd.rs b/compiler/rustc_target/src/spec/targets/aarch64_unknown_netbsd.rs index 461730457aa4a..d02403007cd7c 100644 --- a/compiler/rustc_target/src/spec/targets/aarch64_unknown_netbsd.rs +++ b/compiler/rustc_target/src/spec/targets/aarch64_unknown_netbsd.rs @@ -1,4 +1,4 @@ -use crate::spec::{StackProbeType, Target, TargetMetadata, TargetOptions, base}; +use crate::spec::{Arch, StackProbeType, Target, TargetMetadata, TargetOptions, base}; pub(crate) fn target() -> Target { Target { @@ -11,7 +11,7 @@ pub(crate) fn target() -> Target { }, pointer_width: 64, data_layout: "e-m:e-p270:32:32-p271:32:32-p272:64:64-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128-Fn32".into(), - arch: "aarch64".into(), + arch: Arch::AArch64, options: TargetOptions { features: "+v8a".into(), mcount: "__mcount".into(), diff --git a/compiler/rustc_target/src/spec/targets/aarch64_unknown_none.rs b/compiler/rustc_target/src/spec/targets/aarch64_unknown_none.rs index 6c14f5df4660a..ffb136366acc6 100644 --- a/compiler/rustc_target/src/spec/targets/aarch64_unknown_none.rs +++ b/compiler/rustc_target/src/spec/targets/aarch64_unknown_none.rs @@ -7,7 +7,7 @@ // For example, `-C target-cpu=cortex-a53`. use crate::spec::{ - Cc, LinkerFlavor, Lld, PanicStrategy, RelocModel, SanitizerSet, StackProbeType, Target, + Arch, Cc, LinkerFlavor, Lld, PanicStrategy, RelocModel, SanitizerSet, StackProbeType, Target, TargetMetadata, TargetOptions, }; @@ -39,7 +39,7 @@ pub(crate) fn target() -> Target { }, pointer_width: 64, data_layout: "e-m:e-p270:32:32-p271:32:32-p272:64:64-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128-Fn32".into(), - arch: "aarch64".into(), + arch: Arch::AArch64, options: opts, } } diff --git a/compiler/rustc_target/src/spec/targets/aarch64_unknown_none_softfloat.rs b/compiler/rustc_target/src/spec/targets/aarch64_unknown_none_softfloat.rs index 35a4dd72b8628..387fef3074d49 100644 --- a/compiler/rustc_target/src/spec/targets/aarch64_unknown_none_softfloat.rs +++ b/compiler/rustc_target/src/spec/targets/aarch64_unknown_none_softfloat.rs @@ -7,7 +7,7 @@ // For example, `-C target-cpu=cortex-a53`. use crate::spec::{ - Cc, LinkerFlavor, Lld, PanicStrategy, RelocModel, SanitizerSet, StackProbeType, Target, + Arch, Cc, LinkerFlavor, Lld, PanicStrategy, RelocModel, SanitizerSet, StackProbeType, Target, TargetMetadata, TargetOptions, }; @@ -35,7 +35,7 @@ pub(crate) fn target() -> Target { }, pointer_width: 64, data_layout: "e-m:e-p270:32:32-p271:32:32-p272:64:64-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128-Fn32".into(), - arch: "aarch64".into(), + arch: Arch::AArch64, options: opts, } } diff --git a/compiler/rustc_target/src/spec/targets/aarch64_unknown_nuttx.rs b/compiler/rustc_target/src/spec/targets/aarch64_unknown_nuttx.rs index 243d84a12ecee..8bcc3e0ae16da 100644 --- a/compiler/rustc_target/src/spec/targets/aarch64_unknown_nuttx.rs +++ b/compiler/rustc_target/src/spec/targets/aarch64_unknown_nuttx.rs @@ -7,7 +7,7 @@ // For example, `-C target-cpu=cortex-a53`. use crate::spec::{ - Cc, LinkerFlavor, Lld, PanicStrategy, RelocModel, SanitizerSet, StackProbeType, Target, + Arch, Cc, LinkerFlavor, Lld, PanicStrategy, RelocModel, SanitizerSet, StackProbeType, Target, TargetMetadata, TargetOptions, cvs, }; @@ -41,7 +41,7 @@ pub(crate) fn target() -> Target { }, pointer_width: 64, data_layout: "e-m:e-p270:32:32-p271:32:32-p272:64:64-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128-Fn32".into(), - arch: "aarch64".into(), + arch: Arch::AArch64, options: opts, } } diff --git a/compiler/rustc_target/src/spec/targets/aarch64_unknown_openbsd.rs b/compiler/rustc_target/src/spec/targets/aarch64_unknown_openbsd.rs index c23006adad6d8..e5e40cb38b911 100644 --- a/compiler/rustc_target/src/spec/targets/aarch64_unknown_openbsd.rs +++ b/compiler/rustc_target/src/spec/targets/aarch64_unknown_openbsd.rs @@ -1,4 +1,4 @@ -use crate::spec::{StackProbeType, Target, TargetMetadata, TargetOptions, base}; +use crate::spec::{Arch, StackProbeType, Target, TargetMetadata, TargetOptions, base}; pub(crate) fn target() -> Target { Target { @@ -11,7 +11,7 @@ pub(crate) fn target() -> Target { }, pointer_width: 64, data_layout: "e-m:e-p270:32:32-p271:32:32-p272:64:64-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128-Fn32".into(), - arch: "aarch64".into(), + arch: Arch::AArch64, options: TargetOptions { features: "+v8a".into(), max_atomic_width: Some(128), diff --git a/compiler/rustc_target/src/spec/targets/aarch64_unknown_redox.rs b/compiler/rustc_target/src/spec/targets/aarch64_unknown_redox.rs index 39fe71528d381..81aac17a933bc 100644 --- a/compiler/rustc_target/src/spec/targets/aarch64_unknown_redox.rs +++ b/compiler/rustc_target/src/spec/targets/aarch64_unknown_redox.rs @@ -1,4 +1,4 @@ -use crate::spec::{StackProbeType, Target, TargetMetadata, base}; +use crate::spec::{Arch, StackProbeType, Target, TargetMetadata, base}; pub(crate) fn target() -> Target { let mut base = base::redox::opts(); @@ -16,7 +16,7 @@ pub(crate) fn target() -> Target { }, pointer_width: 64, data_layout: "e-m:e-p270:32:32-p271:32:32-p272:64:64-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128-Fn32".into(), - arch: "aarch64".into(), + arch: Arch::AArch64, options: base, } } diff --git a/compiler/rustc_target/src/spec/targets/aarch64_unknown_teeos.rs b/compiler/rustc_target/src/spec/targets/aarch64_unknown_teeos.rs index 799ff1a806eef..009f027ca24f5 100644 --- a/compiler/rustc_target/src/spec/targets/aarch64_unknown_teeos.rs +++ b/compiler/rustc_target/src/spec/targets/aarch64_unknown_teeos.rs @@ -1,4 +1,4 @@ -use crate::spec::{StackProbeType, Target, TargetMetadata, base}; +use crate::spec::{Arch, StackProbeType, Target, TargetMetadata, base}; pub(crate) fn target() -> Target { let mut base = base::teeos::opts(); @@ -16,7 +16,7 @@ pub(crate) fn target() -> Target { }, pointer_width: 64, data_layout: "e-m:e-p270:32:32-p271:32:32-p272:64:64-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128-Fn32".into(), - arch: "aarch64".into(), + arch: Arch::AArch64, options: base, } } diff --git a/compiler/rustc_target/src/spec/targets/aarch64_unknown_trusty.rs b/compiler/rustc_target/src/spec/targets/aarch64_unknown_trusty.rs index 05783fde1adf8..3d0560eb7963e 100644 --- a/compiler/rustc_target/src/spec/targets/aarch64_unknown_trusty.rs +++ b/compiler/rustc_target/src/spec/targets/aarch64_unknown_trusty.rs @@ -1,7 +1,8 @@ // Trusty OS target for AArch64. use crate::spec::{ - LinkSelfContainedDefault, PanicStrategy, RelroLevel, Target, TargetMetadata, TargetOptions, + Arch, LinkSelfContainedDefault, PanicStrategy, RelroLevel, Target, TargetMetadata, + TargetOptions, }; pub(crate) fn target() -> Target { @@ -15,7 +16,7 @@ pub(crate) fn target() -> Target { }, pointer_width: 64, data_layout: "e-m:e-p270:32:32-p271:32:32-p272:64:64-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128-Fn32".into(), - arch: "aarch64".into(), + arch: Arch::AArch64, options: TargetOptions { features: "+neon,+fp-armv8,+reserve-x18".into(), executables: true, diff --git a/compiler/rustc_target/src/spec/targets/aarch64_unknown_uefi.rs b/compiler/rustc_target/src/spec/targets/aarch64_unknown_uefi.rs index 327b52389b934..e2c1888e4084e 100644 --- a/compiler/rustc_target/src/spec/targets/aarch64_unknown_uefi.rs +++ b/compiler/rustc_target/src/spec/targets/aarch64_unknown_uefi.rs @@ -1,7 +1,7 @@ // This defines the aarch64 target for UEFI systems as described in the UEFI specification. See the // uefi-base module for generic UEFI options. -use crate::spec::{LinkerFlavor, Lld, Target, TargetMetadata, base}; +use crate::spec::{Arch, LinkerFlavor, Lld, Target, TargetMetadata, base}; pub(crate) fn target() -> Target { let mut base = base::uefi_msvc::opts(); @@ -22,7 +22,7 @@ pub(crate) fn target() -> Target { data_layout: "e-m:w-p270:32:32-p271:32:32-p272:64:64-p:64:64-i32:32-i64:64-i128:128-n32:64-S128-Fn32" .into(), - arch: "aarch64".into(), + arch: Arch::AArch64, options: base, } } diff --git a/compiler/rustc_target/src/spec/targets/aarch64_uwp_windows_msvc.rs b/compiler/rustc_target/src/spec/targets/aarch64_uwp_windows_msvc.rs index a40c8c3a3f26f..0b39b90b97035 100644 --- a/compiler/rustc_target/src/spec/targets/aarch64_uwp_windows_msvc.rs +++ b/compiler/rustc_target/src/spec/targets/aarch64_uwp_windows_msvc.rs @@ -1,4 +1,4 @@ -use crate::spec::{Target, TargetMetadata, base}; +use crate::spec::{Arch, Target, TargetMetadata, base}; pub(crate) fn target() -> Target { let mut base = base::windows_uwp_msvc::opts(); @@ -17,7 +17,7 @@ pub(crate) fn target() -> Target { data_layout: "e-m:w-p270:32:32-p271:32:32-p272:64:64-p:64:64-i32:32-i64:64-i128:128-n32:64-S128-Fn32" .into(), - arch: "aarch64".into(), + arch: Arch::AArch64, options: base, } } diff --git a/compiler/rustc_target/src/spec/targets/aarch64_wrs_vxworks.rs b/compiler/rustc_target/src/spec/targets/aarch64_wrs_vxworks.rs index b68267601838f..679d8941b36f8 100644 --- a/compiler/rustc_target/src/spec/targets/aarch64_wrs_vxworks.rs +++ b/compiler/rustc_target/src/spec/targets/aarch64_wrs_vxworks.rs @@ -1,4 +1,4 @@ -use crate::spec::{StackProbeType, Target, TargetMetadata, TargetOptions, base}; +use crate::spec::{Arch, StackProbeType, Target, TargetMetadata, TargetOptions, base}; pub(crate) fn target() -> Target { Target { @@ -11,7 +11,7 @@ pub(crate) fn target() -> Target { }, pointer_width: 64, data_layout: "e-m:e-p270:32:32-p271:32:32-p272:64:64-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128-Fn32".into(), - arch: "aarch64".into(), + arch: Arch::AArch64, options: TargetOptions { features: "+v8a,+reserve-x18".into(), max_atomic_width: Some(128), diff --git a/compiler/rustc_target/src/spec/targets/amdgcn_amd_amdhsa.rs b/compiler/rustc_target/src/spec/targets/amdgcn_amd_amdhsa.rs index 0d6c6194e2694..07772c7573377 100644 --- a/compiler/rustc_target/src/spec/targets/amdgcn_amd_amdhsa.rs +++ b/compiler/rustc_target/src/spec/targets/amdgcn_amd_amdhsa.rs @@ -1,8 +1,10 @@ -use crate::spec::{Cc, LinkerFlavor, Lld, PanicStrategy, Target, TargetMetadata, TargetOptions}; +use crate::spec::{ + Arch, Cc, LinkerFlavor, Lld, PanicStrategy, Target, TargetMetadata, TargetOptions, +}; pub(crate) fn target() -> Target { Target { - arch: "amdgpu".into(), + arch: Arch::AmdGpu, data_layout: "e-p:64:64-p1:64:64-p2:32:32-p3:32:32-p4:64:64-p5:32:32-p6:32:32-p7:160:256:256:32-p8:128:128:128:48-p9:192:256:256:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64-S32-A5-G1-ni:7:8:9".into(), llvm_target: "amdgcn-amd-amdhsa".into(), metadata: TargetMetadata { diff --git a/compiler/rustc_target/src/spec/targets/arm64ec_pc_windows_msvc.rs b/compiler/rustc_target/src/spec/targets/arm64ec_pc_windows_msvc.rs index 7292412a18d86..aa31f53bf0fcb 100644 --- a/compiler/rustc_target/src/spec/targets/arm64ec_pc_windows_msvc.rs +++ b/compiler/rustc_target/src/spec/targets/arm64ec_pc_windows_msvc.rs @@ -1,4 +1,6 @@ -use crate::spec::{FramePointer, LinkerFlavor, Lld, Target, TargetMetadata, add_link_args, base}; +use crate::spec::{ + Arch, FramePointer, LinkerFlavor, Lld, Target, TargetMetadata, add_link_args, base, +}; pub(crate) fn target() -> Target { let mut base = base::windows_msvc::opts(); @@ -28,7 +30,7 @@ pub(crate) fn target() -> Target { data_layout: "e-m:w-p270:32:32-p271:32:32-p272:64:64-p:64:64-i32:32-i64:64-i128:128-n32:64-S128-Fn32" .into(), - arch: "arm64ec".into(), + arch: Arch::Arm64EC, options: base, } } diff --git a/compiler/rustc_target/src/spec/targets/arm_linux_androideabi.rs b/compiler/rustc_target/src/spec/targets/arm_linux_androideabi.rs index d74468899f56a..dad8f5e1c552a 100644 --- a/compiler/rustc_target/src/spec/targets/arm_linux_androideabi.rs +++ b/compiler/rustc_target/src/spec/targets/arm_linux_androideabi.rs @@ -1,4 +1,4 @@ -use crate::spec::{FloatAbi, SanitizerSet, Target, TargetMetadata, TargetOptions, base}; +use crate::spec::{Arch, FloatAbi, SanitizerSet, Target, TargetMetadata, TargetOptions, base}; pub(crate) fn target() -> Target { Target { @@ -11,7 +11,7 @@ pub(crate) fn target() -> Target { }, pointer_width: 32, data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(), - arch: "arm".into(), + arch: Arch::Arm, options: TargetOptions { abi: "eabi".into(), llvm_floatabi: Some(FloatAbi::Soft), diff --git a/compiler/rustc_target/src/spec/targets/arm_unknown_linux_gnueabi.rs b/compiler/rustc_target/src/spec/targets/arm_unknown_linux_gnueabi.rs index 3b6c97167cf45..55136255babc9 100644 --- a/compiler/rustc_target/src/spec/targets/arm_unknown_linux_gnueabi.rs +++ b/compiler/rustc_target/src/spec/targets/arm_unknown_linux_gnueabi.rs @@ -1,4 +1,4 @@ -use crate::spec::{FloatAbi, Target, TargetMetadata, TargetOptions, base}; +use crate::spec::{Arch, FloatAbi, Target, TargetMetadata, TargetOptions, base}; pub(crate) fn target() -> Target { Target { @@ -11,7 +11,7 @@ pub(crate) fn target() -> Target { }, pointer_width: 32, data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(), - arch: "arm".into(), + arch: Arch::Arm, options: TargetOptions { abi: "eabi".into(), llvm_floatabi: Some(FloatAbi::Soft), diff --git a/compiler/rustc_target/src/spec/targets/arm_unknown_linux_gnueabihf.rs b/compiler/rustc_target/src/spec/targets/arm_unknown_linux_gnueabihf.rs index 0c711d5e71ab4..087d4cfe800dd 100644 --- a/compiler/rustc_target/src/spec/targets/arm_unknown_linux_gnueabihf.rs +++ b/compiler/rustc_target/src/spec/targets/arm_unknown_linux_gnueabihf.rs @@ -1,4 +1,4 @@ -use crate::spec::{FloatAbi, Target, TargetMetadata, TargetOptions, base}; +use crate::spec::{Arch, FloatAbi, Target, TargetMetadata, TargetOptions, base}; pub(crate) fn target() -> Target { Target { @@ -11,7 +11,7 @@ pub(crate) fn target() -> Target { }, pointer_width: 32, data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(), - arch: "arm".into(), + arch: Arch::Arm, options: TargetOptions { abi: "eabihf".into(), llvm_floatabi: Some(FloatAbi::Hard), diff --git a/compiler/rustc_target/src/spec/targets/arm_unknown_linux_musleabi.rs b/compiler/rustc_target/src/spec/targets/arm_unknown_linux_musleabi.rs index d05f4c79b01fe..e5224e4cce482 100644 --- a/compiler/rustc_target/src/spec/targets/arm_unknown_linux_musleabi.rs +++ b/compiler/rustc_target/src/spec/targets/arm_unknown_linux_musleabi.rs @@ -1,4 +1,4 @@ -use crate::spec::{FloatAbi, Target, TargetMetadata, TargetOptions, base}; +use crate::spec::{Arch, FloatAbi, Target, TargetMetadata, TargetOptions, base}; pub(crate) fn target() -> Target { Target { @@ -11,7 +11,7 @@ pub(crate) fn target() -> Target { }, pointer_width: 32, data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(), - arch: "arm".into(), + arch: Arch::Arm, options: TargetOptions { abi: "eabi".into(), llvm_floatabi: Some(FloatAbi::Soft), diff --git a/compiler/rustc_target/src/spec/targets/arm_unknown_linux_musleabihf.rs b/compiler/rustc_target/src/spec/targets/arm_unknown_linux_musleabihf.rs index 9ce752efd6aa2..0e958455994ce 100644 --- a/compiler/rustc_target/src/spec/targets/arm_unknown_linux_musleabihf.rs +++ b/compiler/rustc_target/src/spec/targets/arm_unknown_linux_musleabihf.rs @@ -1,4 +1,4 @@ -use crate::spec::{FloatAbi, Target, TargetMetadata, TargetOptions, base}; +use crate::spec::{Arch, FloatAbi, Target, TargetMetadata, TargetOptions, base}; pub(crate) fn target() -> Target { Target { @@ -11,7 +11,7 @@ pub(crate) fn target() -> Target { }, pointer_width: 32, data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(), - arch: "arm".into(), + arch: Arch::Arm, options: TargetOptions { abi: "eabihf".into(), llvm_floatabi: Some(FloatAbi::Hard), diff --git a/compiler/rustc_target/src/spec/targets/armeb_unknown_linux_gnueabi.rs b/compiler/rustc_target/src/spec/targets/armeb_unknown_linux_gnueabi.rs index afb17fd82032b..a9794f80e6877 100644 --- a/compiler/rustc_target/src/spec/targets/armeb_unknown_linux_gnueabi.rs +++ b/compiler/rustc_target/src/spec/targets/armeb_unknown_linux_gnueabi.rs @@ -1,6 +1,6 @@ use rustc_abi::Endian; -use crate::spec::{FloatAbi, Target, TargetMetadata, TargetOptions, base}; +use crate::spec::{Arch, FloatAbi, Target, TargetMetadata, TargetOptions, base}; pub(crate) fn target() -> Target { Target { @@ -13,7 +13,7 @@ pub(crate) fn target() -> Target { }, pointer_width: 32, data_layout: "E-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(), - arch: "arm".into(), + arch: Arch::Arm, options: TargetOptions { abi: "eabi".into(), llvm_floatabi: Some(FloatAbi::Soft), diff --git a/compiler/rustc_target/src/spec/targets/armebv7r_none_eabi.rs b/compiler/rustc_target/src/spec/targets/armebv7r_none_eabi.rs index 0ae7cd7a3773d..bf9519b8a105f 100644 --- a/compiler/rustc_target/src/spec/targets/armebv7r_none_eabi.rs +++ b/compiler/rustc_target/src/spec/targets/armebv7r_none_eabi.rs @@ -3,7 +3,7 @@ use rustc_abi::Endian; use crate::spec::{ - Cc, FloatAbi, LinkerFlavor, Lld, PanicStrategy, RelocModel, Target, TargetMetadata, + Arch, Cc, FloatAbi, LinkerFlavor, Lld, PanicStrategy, RelocModel, Target, TargetMetadata, TargetOptions, }; @@ -18,7 +18,7 @@ pub(crate) fn target() -> Target { }, pointer_width: 32, data_layout: "E-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(), - arch: "arm".into(), + arch: Arch::Arm, options: TargetOptions { abi: "eabi".into(), llvm_floatabi: Some(FloatAbi::Soft), diff --git a/compiler/rustc_target/src/spec/targets/armebv7r_none_eabihf.rs b/compiler/rustc_target/src/spec/targets/armebv7r_none_eabihf.rs index 71ffd8baed57b..75a4ab4d877a6 100644 --- a/compiler/rustc_target/src/spec/targets/armebv7r_none_eabihf.rs +++ b/compiler/rustc_target/src/spec/targets/armebv7r_none_eabihf.rs @@ -3,7 +3,7 @@ use rustc_abi::Endian; use crate::spec::{ - Cc, FloatAbi, LinkerFlavor, Lld, PanicStrategy, RelocModel, Target, TargetMetadata, + Arch, Cc, FloatAbi, LinkerFlavor, Lld, PanicStrategy, RelocModel, Target, TargetMetadata, TargetOptions, }; @@ -18,7 +18,7 @@ pub(crate) fn target() -> Target { }, pointer_width: 32, data_layout: "E-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(), - arch: "arm".into(), + arch: Arch::Arm, options: TargetOptions { abi: "eabihf".into(), llvm_floatabi: Some(FloatAbi::Hard), diff --git a/compiler/rustc_target/src/spec/targets/armv4t_none_eabi.rs b/compiler/rustc_target/src/spec/targets/armv4t_none_eabi.rs index 9571821656c8c..2bb35bd6ea206 100644 --- a/compiler/rustc_target/src/spec/targets/armv4t_none_eabi.rs +++ b/compiler/rustc_target/src/spec/targets/armv4t_none_eabi.rs @@ -10,7 +10,7 @@ //! `-Clink-arg=-Tmy_script.ld` to override that with a correct linker script. use crate::spec::{ - Cc, FloatAbi, LinkerFlavor, Lld, PanicStrategy, RelocModel, Target, TargetMetadata, + Arch, Cc, FloatAbi, LinkerFlavor, Lld, PanicStrategy, RelocModel, Target, TargetMetadata, TargetOptions, cvs, }; @@ -24,7 +24,7 @@ pub(crate) fn target() -> Target { std: Some(false), }, pointer_width: 32, - arch: "arm".into(), + arch: Arch::Arm, /* Data layout args are '-' separated: * little endian * stack is 64-bit aligned (EABI) diff --git a/compiler/rustc_target/src/spec/targets/armv4t_unknown_linux_gnueabi.rs b/compiler/rustc_target/src/spec/targets/armv4t_unknown_linux_gnueabi.rs index beaec71093cb4..1e13e02045a14 100644 --- a/compiler/rustc_target/src/spec/targets/armv4t_unknown_linux_gnueabi.rs +++ b/compiler/rustc_target/src/spec/targets/armv4t_unknown_linux_gnueabi.rs @@ -1,4 +1,4 @@ -use crate::spec::{FloatAbi, Target, TargetMetadata, TargetOptions, base}; +use crate::spec::{Arch, FloatAbi, Target, TargetMetadata, TargetOptions, base}; pub(crate) fn target() -> Target { Target { @@ -11,7 +11,7 @@ pub(crate) fn target() -> Target { }, pointer_width: 32, data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(), - arch: "arm".into(), + arch: Arch::Arm, options: TargetOptions { abi: "eabi".into(), llvm_floatabi: Some(FloatAbi::Soft), diff --git a/compiler/rustc_target/src/spec/targets/armv5te_none_eabi.rs b/compiler/rustc_target/src/spec/targets/armv5te_none_eabi.rs index 75ab941c5cf29..28f2533d7a362 100644 --- a/compiler/rustc_target/src/spec/targets/armv5te_none_eabi.rs +++ b/compiler/rustc_target/src/spec/targets/armv5te_none_eabi.rs @@ -1,6 +1,6 @@ //! Targets the ARMv5TE, with code as `a32` code by default. -use crate::spec::{FloatAbi, FramePointer, Target, TargetMetadata, TargetOptions, base, cvs}; +use crate::spec::{Arch, FloatAbi, FramePointer, Target, TargetMetadata, TargetOptions, base, cvs}; pub(crate) fn target() -> Target { Target { @@ -12,7 +12,7 @@ pub(crate) fn target() -> Target { std: Some(false), }, pointer_width: 32, - arch: "arm".into(), + arch: Arch::Arm, /* Data layout args are '-' separated: * little endian * stack is 64-bit aligned (EABI) diff --git a/compiler/rustc_target/src/spec/targets/armv5te_unknown_linux_gnueabi.rs b/compiler/rustc_target/src/spec/targets/armv5te_unknown_linux_gnueabi.rs index 7b93672dbe0fa..763d68f0495a3 100644 --- a/compiler/rustc_target/src/spec/targets/armv5te_unknown_linux_gnueabi.rs +++ b/compiler/rustc_target/src/spec/targets/armv5te_unknown_linux_gnueabi.rs @@ -1,4 +1,4 @@ -use crate::spec::{FloatAbi, Target, TargetMetadata, TargetOptions, base}; +use crate::spec::{Arch, FloatAbi, Target, TargetMetadata, TargetOptions, base}; pub(crate) fn target() -> Target { Target { @@ -11,7 +11,7 @@ pub(crate) fn target() -> Target { }, pointer_width: 32, data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(), - arch: "arm".into(), + arch: Arch::Arm, options: TargetOptions { abi: "eabi".into(), llvm_floatabi: Some(FloatAbi::Soft), diff --git a/compiler/rustc_target/src/spec/targets/armv5te_unknown_linux_musleabi.rs b/compiler/rustc_target/src/spec/targets/armv5te_unknown_linux_musleabi.rs index 0240450b61d30..a08d1a1c63ef1 100644 --- a/compiler/rustc_target/src/spec/targets/armv5te_unknown_linux_musleabi.rs +++ b/compiler/rustc_target/src/spec/targets/armv5te_unknown_linux_musleabi.rs @@ -1,4 +1,4 @@ -use crate::spec::{FloatAbi, Target, TargetMetadata, TargetOptions, base}; +use crate::spec::{Arch, FloatAbi, Target, TargetMetadata, TargetOptions, base}; pub(crate) fn target() -> Target { Target { @@ -11,7 +11,7 @@ pub(crate) fn target() -> Target { }, pointer_width: 32, data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(), - arch: "arm".into(), + arch: Arch::Arm, options: TargetOptions { abi: "eabi".into(), llvm_floatabi: Some(FloatAbi::Soft), diff --git a/compiler/rustc_target/src/spec/targets/armv5te_unknown_linux_uclibceabi.rs b/compiler/rustc_target/src/spec/targets/armv5te_unknown_linux_uclibceabi.rs index 860629b08e19b..1719ab7314a42 100644 --- a/compiler/rustc_target/src/spec/targets/armv5te_unknown_linux_uclibceabi.rs +++ b/compiler/rustc_target/src/spec/targets/armv5te_unknown_linux_uclibceabi.rs @@ -1,4 +1,4 @@ -use crate::spec::{FloatAbi, Target, TargetMetadata, TargetOptions, base}; +use crate::spec::{Arch, FloatAbi, Target, TargetMetadata, TargetOptions, base}; pub(crate) fn target() -> Target { Target { @@ -11,7 +11,7 @@ pub(crate) fn target() -> Target { }, pointer_width: 32, data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(), - arch: "arm".into(), + arch: Arch::Arm, options: TargetOptions { abi: "eabi".into(), llvm_floatabi: Some(FloatAbi::Soft), diff --git a/compiler/rustc_target/src/spec/targets/armv6_unknown_freebsd.rs b/compiler/rustc_target/src/spec/targets/armv6_unknown_freebsd.rs index 1625a6b84bbc3..2da15219d6ce0 100644 --- a/compiler/rustc_target/src/spec/targets/armv6_unknown_freebsd.rs +++ b/compiler/rustc_target/src/spec/targets/armv6_unknown_freebsd.rs @@ -1,4 +1,4 @@ -use crate::spec::{FloatAbi, Target, TargetMetadata, TargetOptions, base}; +use crate::spec::{Arch, FloatAbi, Target, TargetMetadata, TargetOptions, base}; pub(crate) fn target() -> Target { Target { @@ -11,7 +11,7 @@ pub(crate) fn target() -> Target { }, pointer_width: 32, data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(), - arch: "arm".into(), + arch: Arch::Arm, options: TargetOptions { abi: "eabihf".into(), llvm_floatabi: Some(FloatAbi::Hard), diff --git a/compiler/rustc_target/src/spec/targets/armv6_unknown_netbsd_eabihf.rs b/compiler/rustc_target/src/spec/targets/armv6_unknown_netbsd_eabihf.rs index af9a43595651a..fbd55a3714879 100644 --- a/compiler/rustc_target/src/spec/targets/armv6_unknown_netbsd_eabihf.rs +++ b/compiler/rustc_target/src/spec/targets/armv6_unknown_netbsd_eabihf.rs @@ -1,4 +1,4 @@ -use crate::spec::{FloatAbi, Target, TargetMetadata, TargetOptions, base}; +use crate::spec::{Arch, FloatAbi, Target, TargetMetadata, TargetOptions, base}; pub(crate) fn target() -> Target { Target { @@ -11,7 +11,7 @@ pub(crate) fn target() -> Target { }, pointer_width: 32, data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(), - arch: "arm".into(), + arch: Arch::Arm, options: TargetOptions { abi: "eabihf".into(), llvm_floatabi: Some(FloatAbi::Hard), diff --git a/compiler/rustc_target/src/spec/targets/armv6k_nintendo_3ds.rs b/compiler/rustc_target/src/spec/targets/armv6k_nintendo_3ds.rs index 4c32a5e621616..a79c642870126 100644 --- a/compiler/rustc_target/src/spec/targets/armv6k_nintendo_3ds.rs +++ b/compiler/rustc_target/src/spec/targets/armv6k_nintendo_3ds.rs @@ -1,5 +1,5 @@ use crate::spec::{ - Cc, FloatAbi, LinkerFlavor, Lld, RelocModel, Target, TargetMetadata, TargetOptions, cvs, + Arch, Cc, FloatAbi, LinkerFlavor, Lld, RelocModel, Target, TargetMetadata, TargetOptions, cvs, }; /// A base target for Nintendo 3DS devices using the devkitARM toolchain. @@ -22,7 +22,7 @@ pub(crate) fn target() -> Target { }, pointer_width: 32, data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(), - arch: "arm".into(), + arch: Arch::Arm, options: TargetOptions { os: "horizon".into(), diff --git a/compiler/rustc_target/src/spec/targets/armv7_linux_androideabi.rs b/compiler/rustc_target/src/spec/targets/armv7_linux_androideabi.rs index 706fb12a524a7..ce6c3c8a6c14c 100644 --- a/compiler/rustc_target/src/spec/targets/armv7_linux_androideabi.rs +++ b/compiler/rustc_target/src/spec/targets/armv7_linux_androideabi.rs @@ -1,5 +1,6 @@ use crate::spec::{ - Cc, FloatAbi, LinkerFlavor, Lld, SanitizerSet, Target, TargetMetadata, TargetOptions, base, + Arch, Cc, FloatAbi, LinkerFlavor, Lld, SanitizerSet, Target, TargetMetadata, TargetOptions, + base, }; // This target if is for the baseline of the Android v7a ABI @@ -23,7 +24,7 @@ pub(crate) fn target() -> Target { }, pointer_width: 32, data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(), - arch: "arm".into(), + arch: Arch::Arm, options: TargetOptions { abi: "eabi".into(), llvm_floatabi: Some(FloatAbi::Soft), diff --git a/compiler/rustc_target/src/spec/targets/armv7_rtems_eabihf.rs b/compiler/rustc_target/src/spec/targets/armv7_rtems_eabihf.rs index c17db36ee6114..0958f617663f8 100644 --- a/compiler/rustc_target/src/spec/targets/armv7_rtems_eabihf.rs +++ b/compiler/rustc_target/src/spec/targets/armv7_rtems_eabihf.rs @@ -1,5 +1,5 @@ use crate::spec::{ - Cc, FloatAbi, LinkerFlavor, Lld, PanicStrategy, RelocModel, Target, TargetMetadata, + Arch, Cc, FloatAbi, LinkerFlavor, Lld, PanicStrategy, RelocModel, Target, TargetMetadata, TargetOptions, cvs, }; @@ -14,7 +14,7 @@ pub(crate) fn target() -> Target { }, pointer_width: 32, data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(), - arch: "arm".into(), + arch: Arch::Arm, options: TargetOptions { os: "rtems".into(), diff --git a/compiler/rustc_target/src/spec/targets/armv7_sony_vita_newlibeabihf.rs b/compiler/rustc_target/src/spec/targets/armv7_sony_vita_newlibeabihf.rs index 4902dc37d13cc..6c02ec26fea48 100644 --- a/compiler/rustc_target/src/spec/targets/armv7_sony_vita_newlibeabihf.rs +++ b/compiler/rustc_target/src/spec/targets/armv7_sony_vita_newlibeabihf.rs @@ -1,7 +1,7 @@ use rustc_abi::Endian; use crate::spec::{ - Cc, FloatAbi, LinkerFlavor, Lld, RelocModel, Target, TargetMetadata, TargetOptions, cvs, + Arch, Cc, FloatAbi, LinkerFlavor, Lld, RelocModel, Target, TargetMetadata, TargetOptions, cvs, }; /// A base target for PlayStation Vita devices using the VITASDK toolchain (using newlib). @@ -26,7 +26,7 @@ pub(crate) fn target() -> Target { }, pointer_width: 32, data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(), - arch: "arm".into(), + arch: Arch::Arm, options: TargetOptions { os: "vita".into(), diff --git a/compiler/rustc_target/src/spec/targets/armv7_unknown_freebsd.rs b/compiler/rustc_target/src/spec/targets/armv7_unknown_freebsd.rs index 56f2e090e0713..63aee180299e0 100644 --- a/compiler/rustc_target/src/spec/targets/armv7_unknown_freebsd.rs +++ b/compiler/rustc_target/src/spec/targets/armv7_unknown_freebsd.rs @@ -1,4 +1,4 @@ -use crate::spec::{FloatAbi, Target, TargetMetadata, TargetOptions, base}; +use crate::spec::{Arch, FloatAbi, Target, TargetMetadata, TargetOptions, base}; pub(crate) fn target() -> Target { Target { @@ -11,7 +11,7 @@ pub(crate) fn target() -> Target { }, pointer_width: 32, data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(), - arch: "arm".into(), + arch: Arch::Arm, options: TargetOptions { abi: "eabihf".into(), llvm_floatabi: Some(FloatAbi::Hard), diff --git a/compiler/rustc_target/src/spec/targets/armv7_unknown_linux_gnueabi.rs b/compiler/rustc_target/src/spec/targets/armv7_unknown_linux_gnueabi.rs index 603afe2c48bb9..6288095fcf4cb 100644 --- a/compiler/rustc_target/src/spec/targets/armv7_unknown_linux_gnueabi.rs +++ b/compiler/rustc_target/src/spec/targets/armv7_unknown_linux_gnueabi.rs @@ -1,4 +1,4 @@ -use crate::spec::{FloatAbi, Target, TargetMetadata, TargetOptions, base}; +use crate::spec::{Arch, FloatAbi, Target, TargetMetadata, TargetOptions, base}; // This target is for glibc Linux on ARMv7 without thumb-mode, NEON or // hardfloat. @@ -14,7 +14,7 @@ pub(crate) fn target() -> Target { }, pointer_width: 32, data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(), - arch: "arm".into(), + arch: Arch::Arm, options: TargetOptions { abi: "eabi".into(), llvm_floatabi: Some(FloatAbi::Soft), diff --git a/compiler/rustc_target/src/spec/targets/armv7_unknown_linux_gnueabihf.rs b/compiler/rustc_target/src/spec/targets/armv7_unknown_linux_gnueabihf.rs index a3b35d658e9da..57374b8af9d76 100644 --- a/compiler/rustc_target/src/spec/targets/armv7_unknown_linux_gnueabihf.rs +++ b/compiler/rustc_target/src/spec/targets/armv7_unknown_linux_gnueabihf.rs @@ -1,4 +1,4 @@ -use crate::spec::{FloatAbi, Target, TargetMetadata, TargetOptions, base}; +use crate::spec::{Arch, FloatAbi, Target, TargetMetadata, TargetOptions, base}; // This target is for glibc Linux on ARMv7 without NEON or // thumb-mode. See the thumbv7neon variant for enabling both. @@ -14,7 +14,7 @@ pub(crate) fn target() -> Target { }, pointer_width: 32, data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(), - arch: "arm".into(), + arch: Arch::Arm, options: TargetOptions { abi: "eabihf".into(), llvm_floatabi: Some(FloatAbi::Hard), diff --git a/compiler/rustc_target/src/spec/targets/armv7_unknown_linux_musleabi.rs b/compiler/rustc_target/src/spec/targets/armv7_unknown_linux_musleabi.rs index dd8a97bf77f65..20545aba821f4 100644 --- a/compiler/rustc_target/src/spec/targets/armv7_unknown_linux_musleabi.rs +++ b/compiler/rustc_target/src/spec/targets/armv7_unknown_linux_musleabi.rs @@ -1,4 +1,4 @@ -use crate::spec::{FloatAbi, Target, TargetMetadata, TargetOptions, base}; +use crate::spec::{Arch, FloatAbi, Target, TargetMetadata, TargetOptions, base}; // This target is for musl Linux on ARMv7 without thumb-mode, NEON or // hardfloat. @@ -16,7 +16,7 @@ pub(crate) fn target() -> Target { }, pointer_width: 32, data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(), - arch: "arm".into(), + arch: Arch::Arm, options: TargetOptions { abi: "eabi".into(), diff --git a/compiler/rustc_target/src/spec/targets/armv7_unknown_linux_musleabihf.rs b/compiler/rustc_target/src/spec/targets/armv7_unknown_linux_musleabihf.rs index c3b7ac5f994c2..7028f430ff8f3 100644 --- a/compiler/rustc_target/src/spec/targets/armv7_unknown_linux_musleabihf.rs +++ b/compiler/rustc_target/src/spec/targets/armv7_unknown_linux_musleabihf.rs @@ -1,4 +1,4 @@ -use crate::spec::{FloatAbi, Target, TargetMetadata, TargetOptions, base}; +use crate::spec::{Arch, FloatAbi, Target, TargetMetadata, TargetOptions, base}; // This target is for musl Linux on ARMv7 without thumb-mode or NEON. @@ -13,7 +13,7 @@ pub(crate) fn target() -> Target { }, pointer_width: 32, data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(), - arch: "arm".into(), + arch: Arch::Arm, // Most of these settings are copied from the armv7_unknown_linux_gnueabihf // target. diff --git a/compiler/rustc_target/src/spec/targets/armv7_unknown_linux_ohos.rs b/compiler/rustc_target/src/spec/targets/armv7_unknown_linux_ohos.rs index f31dedb04e6ca..f0946183fcad2 100644 --- a/compiler/rustc_target/src/spec/targets/armv7_unknown_linux_ohos.rs +++ b/compiler/rustc_target/src/spec/targets/armv7_unknown_linux_ohos.rs @@ -1,4 +1,4 @@ -use crate::spec::{FloatAbi, Target, TargetMetadata, TargetOptions, base}; +use crate::spec::{Arch, FloatAbi, Target, TargetMetadata, TargetOptions, base}; // This target is for OpenHarmony on ARMv7 Linux with thumb-mode, but no NEON or // hardfloat. @@ -16,7 +16,7 @@ pub(crate) fn target() -> Target { }, pointer_width: 32, data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(), - arch: "arm".into(), + arch: Arch::Arm, options: TargetOptions { abi: "eabi".into(), diff --git a/compiler/rustc_target/src/spec/targets/armv7_unknown_linux_uclibceabi.rs b/compiler/rustc_target/src/spec/targets/armv7_unknown_linux_uclibceabi.rs index a9e9f4651bb28..c2cc2526ec3f6 100644 --- a/compiler/rustc_target/src/spec/targets/armv7_unknown_linux_uclibceabi.rs +++ b/compiler/rustc_target/src/spec/targets/armv7_unknown_linux_uclibceabi.rs @@ -1,4 +1,4 @@ -use crate::spec::{FloatAbi, Target, TargetMetadata, TargetOptions, base}; +use crate::spec::{Arch, FloatAbi, Target, TargetMetadata, TargetOptions, base}; // This target is for uclibc Linux on ARMv7 without NEON, // thumb-mode or hardfloat. @@ -15,7 +15,7 @@ pub(crate) fn target() -> Target { }, pointer_width: 32, data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(), - arch: "arm".into(), + arch: Arch::Arm, options: TargetOptions { abi: "eabi".into(), diff --git a/compiler/rustc_target/src/spec/targets/armv7_unknown_linux_uclibceabihf.rs b/compiler/rustc_target/src/spec/targets/armv7_unknown_linux_uclibceabihf.rs index a95f12d0230d6..0649ba3c5ed57 100644 --- a/compiler/rustc_target/src/spec/targets/armv7_unknown_linux_uclibceabihf.rs +++ b/compiler/rustc_target/src/spec/targets/armv7_unknown_linux_uclibceabihf.rs @@ -1,4 +1,4 @@ -use crate::spec::{FloatAbi, Target, TargetMetadata, TargetOptions, base}; +use crate::spec::{Arch, FloatAbi, Target, TargetMetadata, TargetOptions, base}; // This target is for uclibc Linux on ARMv7 without NEON or // thumb-mode. See the thumbv7neon variant for enabling both. @@ -15,7 +15,7 @@ pub(crate) fn target() -> Target { }, pointer_width: 32, data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(), - arch: "arm".into(), + arch: Arch::Arm, options: TargetOptions { // Info about features at https://wiki.debian.org/ArmHardFloatPort diff --git a/compiler/rustc_target/src/spec/targets/armv7_unknown_netbsd_eabihf.rs b/compiler/rustc_target/src/spec/targets/armv7_unknown_netbsd_eabihf.rs index d155dc58e5113..d6cb517759d9a 100644 --- a/compiler/rustc_target/src/spec/targets/armv7_unknown_netbsd_eabihf.rs +++ b/compiler/rustc_target/src/spec/targets/armv7_unknown_netbsd_eabihf.rs @@ -1,4 +1,4 @@ -use crate::spec::{FloatAbi, Target, TargetMetadata, TargetOptions, base}; +use crate::spec::{Arch, FloatAbi, Target, TargetMetadata, TargetOptions, base}; pub(crate) fn target() -> Target { Target { @@ -11,7 +11,7 @@ pub(crate) fn target() -> Target { }, pointer_width: 32, data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(), - arch: "arm".into(), + arch: Arch::Arm, options: TargetOptions { abi: "eabihf".into(), llvm_floatabi: Some(FloatAbi::Hard), diff --git a/compiler/rustc_target/src/spec/targets/armv7_unknown_trusty.rs b/compiler/rustc_target/src/spec/targets/armv7_unknown_trusty.rs index 2b0b0e1d1170d..765d1982a6793 100644 --- a/compiler/rustc_target/src/spec/targets/armv7_unknown_trusty.rs +++ b/compiler/rustc_target/src/spec/targets/armv7_unknown_trusty.rs @@ -1,5 +1,5 @@ use crate::spec::{ - FloatAbi, LinkSelfContainedDefault, PanicStrategy, RelroLevel, Target, TargetMetadata, + Arch, FloatAbi, LinkSelfContainedDefault, PanicStrategy, RelroLevel, Target, TargetMetadata, TargetOptions, }; @@ -17,7 +17,7 @@ pub(crate) fn target() -> Target { }, pointer_width: 32, data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(), - arch: "arm".into(), + arch: Arch::Arm, options: TargetOptions { abi: "eabi".into(), llvm_floatabi: Some(FloatAbi::Soft), diff --git a/compiler/rustc_target/src/spec/targets/armv7_wrs_vxworks_eabihf.rs b/compiler/rustc_target/src/spec/targets/armv7_wrs_vxworks_eabihf.rs index 05be389b57c37..ef261150f220f 100644 --- a/compiler/rustc_target/src/spec/targets/armv7_wrs_vxworks_eabihf.rs +++ b/compiler/rustc_target/src/spec/targets/armv7_wrs_vxworks_eabihf.rs @@ -1,4 +1,4 @@ -use crate::spec::{FloatAbi, Target, TargetMetadata, TargetOptions, base}; +use crate::spec::{Arch, FloatAbi, Target, TargetMetadata, TargetOptions, base}; pub(crate) fn target() -> Target { Target { @@ -11,7 +11,7 @@ pub(crate) fn target() -> Target { }, pointer_width: 32, data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(), - arch: "arm".into(), + arch: Arch::Arm, options: TargetOptions { abi: "eabihf".into(), llvm_floatabi: Some(FloatAbi::Hard), diff --git a/compiler/rustc_target/src/spec/targets/armv7a_kmc_solid_asp3_eabi.rs b/compiler/rustc_target/src/spec/targets/armv7a_kmc_solid_asp3_eabi.rs index 26c2513998919..3ceeef4e06966 100644 --- a/compiler/rustc_target/src/spec/targets/armv7a_kmc_solid_asp3_eabi.rs +++ b/compiler/rustc_target/src/spec/targets/armv7a_kmc_solid_asp3_eabi.rs @@ -1,4 +1,4 @@ -use crate::spec::{FloatAbi, RelocModel, Target, TargetMetadata, TargetOptions, base}; +use crate::spec::{Arch, FloatAbi, RelocModel, Target, TargetMetadata, TargetOptions, base}; pub(crate) fn target() -> Target { let base = base::solid::opts("asp3"); @@ -12,7 +12,7 @@ pub(crate) fn target() -> Target { }, pointer_width: 32, data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(), - arch: "arm".into(), + arch: Arch::Arm, options: TargetOptions { abi: "eabi".into(), llvm_floatabi: Some(FloatAbi::Soft), diff --git a/compiler/rustc_target/src/spec/targets/armv7a_kmc_solid_asp3_eabihf.rs b/compiler/rustc_target/src/spec/targets/armv7a_kmc_solid_asp3_eabihf.rs index 7032444bea4ca..65af0bda5dfef 100644 --- a/compiler/rustc_target/src/spec/targets/armv7a_kmc_solid_asp3_eabihf.rs +++ b/compiler/rustc_target/src/spec/targets/armv7a_kmc_solid_asp3_eabihf.rs @@ -1,4 +1,4 @@ -use crate::spec::{FloatAbi, RelocModel, Target, TargetMetadata, TargetOptions, base}; +use crate::spec::{Arch, FloatAbi, RelocModel, Target, TargetMetadata, TargetOptions, base}; pub(crate) fn target() -> Target { let base = base::solid::opts("asp3"); @@ -12,7 +12,7 @@ pub(crate) fn target() -> Target { }, pointer_width: 32, data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(), - arch: "arm".into(), + arch: Arch::Arm, options: TargetOptions { abi: "eabihf".into(), llvm_floatabi: Some(FloatAbi::Hard), diff --git a/compiler/rustc_target/src/spec/targets/armv7a_none_eabi.rs b/compiler/rustc_target/src/spec/targets/armv7a_none_eabi.rs index fb1d7d6c39d73..3d4328abe9b4c 100644 --- a/compiler/rustc_target/src/spec/targets/armv7a_none_eabi.rs +++ b/compiler/rustc_target/src/spec/targets/armv7a_none_eabi.rs @@ -15,7 +15,7 @@ // linking. rationale: matches `thumb` targets use crate::spec::{ - Cc, FloatAbi, LinkerFlavor, Lld, PanicStrategy, RelocModel, Target, TargetMetadata, + Arch, Cc, FloatAbi, LinkerFlavor, Lld, PanicStrategy, RelocModel, Target, TargetMetadata, TargetOptions, }; @@ -44,7 +44,7 @@ pub(crate) fn target() -> Target { }, pointer_width: 32, data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(), - arch: "arm".into(), + arch: Arch::Arm, options: opts, } } diff --git a/compiler/rustc_target/src/spec/targets/armv7a_none_eabihf.rs b/compiler/rustc_target/src/spec/targets/armv7a_none_eabihf.rs index 217a79d4571e9..e3c5dce88fc17 100644 --- a/compiler/rustc_target/src/spec/targets/armv7a_none_eabihf.rs +++ b/compiler/rustc_target/src/spec/targets/armv7a_none_eabihf.rs @@ -6,7 +6,7 @@ // `thumb` & `aarch64` targets. use crate::spec::{ - Cc, FloatAbi, LinkerFlavor, Lld, PanicStrategy, RelocModel, Target, TargetMetadata, + Arch, Cc, FloatAbi, LinkerFlavor, Lld, PanicStrategy, RelocModel, Target, TargetMetadata, TargetOptions, }; @@ -36,7 +36,7 @@ pub(crate) fn target() -> Target { }, pointer_width: 32, data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(), - arch: "arm".into(), + arch: Arch::Arm, options: opts, } } diff --git a/compiler/rustc_target/src/spec/targets/armv7a_nuttx_eabi.rs b/compiler/rustc_target/src/spec/targets/armv7a_nuttx_eabi.rs index 052285b98dc8a..93302540795d3 100644 --- a/compiler/rustc_target/src/spec/targets/armv7a_nuttx_eabi.rs +++ b/compiler/rustc_target/src/spec/targets/armv7a_nuttx_eabi.rs @@ -5,7 +5,7 @@ // configuration without hardware floating point support. use crate::spec::{ - Cc, FloatAbi, LinkerFlavor, Lld, PanicStrategy, RelocModel, Target, TargetMetadata, + Arch, Cc, FloatAbi, LinkerFlavor, Lld, PanicStrategy, RelocModel, Target, TargetMetadata, TargetOptions, cvs, }; @@ -36,7 +36,7 @@ pub(crate) fn target() -> Target { }, pointer_width: 32, data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(), - arch: "arm".into(), + arch: Arch::Arm, options: opts, } } diff --git a/compiler/rustc_target/src/spec/targets/armv7a_nuttx_eabihf.rs b/compiler/rustc_target/src/spec/targets/armv7a_nuttx_eabihf.rs index 85543e95616b9..864517557c30f 100644 --- a/compiler/rustc_target/src/spec/targets/armv7a_nuttx_eabihf.rs +++ b/compiler/rustc_target/src/spec/targets/armv7a_nuttx_eabihf.rs @@ -5,7 +5,7 @@ // configuration with hardware floating point support. use crate::spec::{ - Cc, FloatAbi, LinkerFlavor, Lld, PanicStrategy, RelocModel, Target, TargetMetadata, + Arch, Cc, FloatAbi, LinkerFlavor, Lld, PanicStrategy, RelocModel, Target, TargetMetadata, TargetOptions, cvs, }; @@ -36,7 +36,7 @@ pub(crate) fn target() -> Target { }, pointer_width: 32, data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(), - arch: "arm".into(), + arch: Arch::Arm, options: opts, } } diff --git a/compiler/rustc_target/src/spec/targets/armv7a_vex_v5.rs b/compiler/rustc_target/src/spec/targets/armv7a_vex_v5.rs index 06dd26297758f..6da1a35474acc 100644 --- a/compiler/rustc_target/src/spec/targets/armv7a_vex_v5.rs +++ b/compiler/rustc_target/src/spec/targets/armv7a_vex_v5.rs @@ -1,5 +1,5 @@ use crate::spec::{ - Cc, FloatAbi, LinkerFlavor, Lld, PanicStrategy, RelocModel, Target, TargetMetadata, + Arch, Cc, FloatAbi, LinkerFlavor, Lld, PanicStrategy, RelocModel, Target, TargetMetadata, TargetOptions, }; @@ -38,7 +38,7 @@ pub(crate) fn target() -> Target { }, pointer_width: 32, data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(), - arch: "arm".into(), + arch: Arch::Arm, options: opts, } } diff --git a/compiler/rustc_target/src/spec/targets/armv7r_none_eabi.rs b/compiler/rustc_target/src/spec/targets/armv7r_none_eabi.rs index 334be483daa0f..bd07e724901c6 100644 --- a/compiler/rustc_target/src/spec/targets/armv7r_none_eabi.rs +++ b/compiler/rustc_target/src/spec/targets/armv7r_none_eabi.rs @@ -1,7 +1,7 @@ // Targets the Little-endian Cortex-R4/R5 processor (ARMv7-R) use crate::spec::{ - Cc, FloatAbi, LinkerFlavor, Lld, PanicStrategy, RelocModel, Target, TargetMetadata, + Arch, Cc, FloatAbi, LinkerFlavor, Lld, PanicStrategy, RelocModel, Target, TargetMetadata, TargetOptions, }; @@ -16,7 +16,7 @@ pub(crate) fn target() -> Target { }, pointer_width: 32, data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(), - arch: "arm".into(), + arch: Arch::Arm, options: TargetOptions { abi: "eabi".into(), diff --git a/compiler/rustc_target/src/spec/targets/armv7r_none_eabihf.rs b/compiler/rustc_target/src/spec/targets/armv7r_none_eabihf.rs index 2bb3e70483ae0..2f89f8042c4af 100644 --- a/compiler/rustc_target/src/spec/targets/armv7r_none_eabihf.rs +++ b/compiler/rustc_target/src/spec/targets/armv7r_none_eabihf.rs @@ -1,7 +1,7 @@ // Targets the Little-endian Cortex-R4F/R5F processor (ARMv7-R) use crate::spec::{ - Cc, FloatAbi, LinkerFlavor, Lld, PanicStrategy, RelocModel, Target, TargetMetadata, + Arch, Cc, FloatAbi, LinkerFlavor, Lld, PanicStrategy, RelocModel, Target, TargetMetadata, TargetOptions, }; @@ -16,7 +16,7 @@ pub(crate) fn target() -> Target { }, pointer_width: 32, data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(), - arch: "arm".into(), + arch: Arch::Arm, options: TargetOptions { abi: "eabihf".into(), diff --git a/compiler/rustc_target/src/spec/targets/armv8r_none_eabihf.rs b/compiler/rustc_target/src/spec/targets/armv8r_none_eabihf.rs index d6e3a03bbba8b..58bd9fafde966 100644 --- a/compiler/rustc_target/src/spec/targets/armv8r_none_eabihf.rs +++ b/compiler/rustc_target/src/spec/targets/armv8r_none_eabihf.rs @@ -1,7 +1,7 @@ // Targets the Little-endian Cortex-R52 processor (ARMv8-R) use crate::spec::{ - Cc, FloatAbi, LinkerFlavor, Lld, PanicStrategy, RelocModel, Target, TargetMetadata, + Arch, Cc, FloatAbi, LinkerFlavor, Lld, PanicStrategy, RelocModel, Target, TargetMetadata, TargetOptions, }; @@ -16,7 +16,7 @@ pub(crate) fn target() -> Target { }, pointer_width: 32, data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(), - arch: "arm".into(), + arch: Arch::Arm, options: TargetOptions { abi: "eabihf".into(), diff --git a/compiler/rustc_target/src/spec/targets/avr_none.rs b/compiler/rustc_target/src/spec/targets/avr_none.rs index 65a171e4515af..eaf4e956f55ec 100644 --- a/compiler/rustc_target/src/spec/targets/avr_none.rs +++ b/compiler/rustc_target/src/spec/targets/avr_none.rs @@ -1,8 +1,8 @@ -use crate::spec::{Cc, LinkerFlavor, Lld, RelocModel, Target, TargetOptions}; +use crate::spec::{Arch, Cc, LinkerFlavor, Lld, RelocModel, Target, TargetOptions}; pub(crate) fn target() -> Target { Target { - arch: "avr".into(), + arch: Arch::Avr, metadata: crate::spec::TargetMetadata { description: None, tier: Some(3), diff --git a/compiler/rustc_target/src/spec/targets/bpfeb_unknown_none.rs b/compiler/rustc_target/src/spec/targets/bpfeb_unknown_none.rs index 3d39cd26c6502..d4a40b2e24c01 100644 --- a/compiler/rustc_target/src/spec/targets/bpfeb_unknown_none.rs +++ b/compiler/rustc_target/src/spec/targets/bpfeb_unknown_none.rs @@ -1,6 +1,6 @@ use rustc_abi::Endian; -use crate::spec::{Target, TargetMetadata, base}; +use crate::spec::{Arch, Target, TargetMetadata, base}; pub(crate) fn target() -> Target { Target { @@ -13,7 +13,7 @@ pub(crate) fn target() -> Target { }, data_layout: "E-m:e-p:64:64-i64:64-i128:128-n32:64-S128".into(), pointer_width: 64, - arch: "bpf".into(), + arch: Arch::Bpf, options: base::bpf::opts(Endian::Big), } } diff --git a/compiler/rustc_target/src/spec/targets/bpfel_unknown_none.rs b/compiler/rustc_target/src/spec/targets/bpfel_unknown_none.rs index 51f45b0124494..f9c5f0956d242 100644 --- a/compiler/rustc_target/src/spec/targets/bpfel_unknown_none.rs +++ b/compiler/rustc_target/src/spec/targets/bpfel_unknown_none.rs @@ -1,6 +1,6 @@ use rustc_abi::Endian; -use crate::spec::{Target, TargetMetadata, base}; +use crate::spec::{Arch, Target, TargetMetadata, base}; pub(crate) fn target() -> Target { Target { @@ -13,7 +13,7 @@ pub(crate) fn target() -> Target { }, data_layout: "e-m:e-p:64:64-i64:64-i128:128-n32:64-S128".into(), pointer_width: 64, - arch: "bpf".into(), + arch: Arch::Bpf, options: base::bpf::opts(Endian::Little), } } diff --git a/compiler/rustc_target/src/spec/targets/csky_unknown_linux_gnuabiv2.rs b/compiler/rustc_target/src/spec/targets/csky_unknown_linux_gnuabiv2.rs index 6142c1541f0b9..1f7f7899f3a68 100644 --- a/compiler/rustc_target/src/spec/targets/csky_unknown_linux_gnuabiv2.rs +++ b/compiler/rustc_target/src/spec/targets/csky_unknown_linux_gnuabiv2.rs @@ -1,4 +1,4 @@ -use crate::spec::{Cc, LinkerFlavor, Lld, Target, TargetMetadata, TargetOptions, base}; +use crate::spec::{Arch, Cc, LinkerFlavor, Lld, Target, TargetMetadata, TargetOptions, base}; // This target is for glibc Linux on Csky @@ -14,7 +14,7 @@ pub(crate) fn target() -> Target { }, pointer_width: 32, data_layout: "e-m:e-S32-p:32:32-i32:32:32-i64:32:32-f32:32:32-f64:32:32-v64:32:32-v128:32:32-a:0:32-Fi32-n32".into(), - arch: "csky".into(), + arch: Arch::CSky, options: TargetOptions { abi: "abiv2".into(), features: "+2e3,+3e7,+7e10,+cache,+dsp1e2,+dspe60,+e1,+e2,+edsp,+elrw,+hard-tp,+high-registers,+hwdiv,+mp,+mp1e2,+nvic,+trust".into(), diff --git a/compiler/rustc_target/src/spec/targets/csky_unknown_linux_gnuabiv2hf.rs b/compiler/rustc_target/src/spec/targets/csky_unknown_linux_gnuabiv2hf.rs index c233ec3ada731..68fdb69fe9d8b 100644 --- a/compiler/rustc_target/src/spec/targets/csky_unknown_linux_gnuabiv2hf.rs +++ b/compiler/rustc_target/src/spec/targets/csky_unknown_linux_gnuabiv2hf.rs @@ -1,4 +1,4 @@ -use crate::spec::{Cc, LinkerFlavor, Lld, Target, TargetMetadata, TargetOptions, base}; +use crate::spec::{Arch, Cc, LinkerFlavor, Lld, Target, TargetMetadata, TargetOptions, base}; // This target is for glibc Linux on Csky @@ -14,7 +14,7 @@ pub(crate) fn target() -> Target { }, pointer_width: 32, data_layout: "e-m:e-S32-p:32:32-i32:32:32-i64:32:32-f32:32:32-f64:32:32-v64:32:32-v128:32:32-a:0:32-Fi32-n32".into(), - arch: "csky".into(), + arch: Arch::CSky, options: TargetOptions { abi: "abiv2hf".into(), cpu: "ck860fv".into(), diff --git a/compiler/rustc_target/src/spec/targets/hexagon_unknown_linux_musl.rs b/compiler/rustc_target/src/spec/targets/hexagon_unknown_linux_musl.rs index 74a7eab1e0c48..17b371f05e530 100644 --- a/compiler/rustc_target/src/spec/targets/hexagon_unknown_linux_musl.rs +++ b/compiler/rustc_target/src/spec/targets/hexagon_unknown_linux_musl.rs @@ -1,4 +1,4 @@ -use crate::spec::{Cc, LinkerFlavor, Target, TargetMetadata, base}; +use crate::spec::{Arch, Cc, LinkerFlavor, Target, TargetMetadata, base}; pub(crate) fn target() -> Target { let mut base = base::linux_musl::opts(); @@ -28,7 +28,7 @@ pub(crate) fn target() -> Target { ":2048:2048" ) .into(), - arch: "hexagon".into(), + arch: Arch::Hexagon, options: base, } } diff --git a/compiler/rustc_target/src/spec/targets/hexagon_unknown_none_elf.rs b/compiler/rustc_target/src/spec/targets/hexagon_unknown_none_elf.rs index e5a927d0953a7..6379cd30c3559 100644 --- a/compiler/rustc_target/src/spec/targets/hexagon_unknown_none_elf.rs +++ b/compiler/rustc_target/src/spec/targets/hexagon_unknown_none_elf.rs @@ -1,4 +1,4 @@ -use crate::spec::{PanicStrategy, Target, TargetMetadata, TargetOptions}; +use crate::spec::{Arch, PanicStrategy, Target, TargetMetadata, TargetOptions}; pub(crate) fn target() -> Target { Target { @@ -17,7 +17,7 @@ pub(crate) fn target() -> Target { ":2048:2048" ) .into(), - arch: "hexagon".into(), + arch: Arch::Hexagon, options: TargetOptions { cpu: "hexagonv60".into(), diff --git a/compiler/rustc_target/src/spec/targets/i586_unknown_netbsd.rs b/compiler/rustc_target/src/spec/targets/i586_unknown_netbsd.rs index 39a71cf178126..92889d6f35178 100644 --- a/compiler/rustc_target/src/spec/targets/i586_unknown_netbsd.rs +++ b/compiler/rustc_target/src/spec/targets/i586_unknown_netbsd.rs @@ -1,4 +1,4 @@ -use crate::spec::{StackProbeType, Target, TargetMetadata, TargetOptions, base}; +use crate::spec::{Arch, StackProbeType, Target, TargetMetadata, TargetOptions, base}; pub(crate) fn target() -> Target { let mut base = base::netbsd::opts(); @@ -18,7 +18,7 @@ pub(crate) fn target() -> Target { data_layout: "e-m:e-p:32:32-p270:32:32-p271:32:32-p272:64:64-\ i128:128-f64:32:64-f80:32-n8:16:32-S128" .into(), - arch: "x86".into(), + arch: Arch::X86, options: TargetOptions { mcount: "__mcount".into(), ..base }, } } diff --git a/compiler/rustc_target/src/spec/targets/i586_unknown_redox.rs b/compiler/rustc_target/src/spec/targets/i586_unknown_redox.rs index 08281eda42e0c..935666630daec 100644 --- a/compiler/rustc_target/src/spec/targets/i586_unknown_redox.rs +++ b/compiler/rustc_target/src/spec/targets/i586_unknown_redox.rs @@ -1,4 +1,4 @@ -use crate::spec::{Cc, LinkerFlavor, Lld, StackProbeType, Target, TargetMetadata, base}; +use crate::spec::{Arch, Cc, LinkerFlavor, Lld, StackProbeType, Target, TargetMetadata, base}; pub(crate) fn target() -> Target { let mut base = base::redox::opts(); @@ -16,7 +16,7 @@ pub(crate) fn target() -> Target { data_layout: "e-m:e-p:32:32-p270:32:32-p271:32:32-p272:64:64-i128:128-f64:32:64-f80:32-n8:16:32-S128" .into(), - arch: "x86".into(), + arch: Arch::X86, options: base, } } diff --git a/compiler/rustc_target/src/spec/targets/i686_linux_android.rs b/compiler/rustc_target/src/spec/targets/i686_linux_android.rs index f2d7ec6644392..b4716f8f3ee92 100644 --- a/compiler/rustc_target/src/spec/targets/i686_linux_android.rs +++ b/compiler/rustc_target/src/spec/targets/i686_linux_android.rs @@ -1,5 +1,5 @@ use crate::spec::{ - RustcAbi, SanitizerSet, StackProbeType, Target, TargetMetadata, TargetOptions, base, + Arch, RustcAbi, SanitizerSet, StackProbeType, Target, TargetMetadata, TargetOptions, base, }; // See https://developer.android.com/ndk/guides/abis.html#x86 @@ -28,7 +28,7 @@ pub(crate) fn target() -> Target { data_layout: "e-m:e-p:32:32-p270:32:32-p271:32:32-p272:64:64-\ i128:128-f64:32:64-f80:32-n8:16:32-S128" .into(), - arch: "x86".into(), + arch: Arch::X86, options: TargetOptions { supported_sanitizers: SanitizerSet::ADDRESS, ..base }, } } diff --git a/compiler/rustc_target/src/spec/targets/i686_pc_nto_qnx700.rs b/compiler/rustc_target/src/spec/targets/i686_pc_nto_qnx700.rs index 6a98a763b364d..af7f3b6b8563d 100644 --- a/compiler/rustc_target/src/spec/targets/i686_pc_nto_qnx700.rs +++ b/compiler/rustc_target/src/spec/targets/i686_pc_nto_qnx700.rs @@ -1,5 +1,5 @@ use crate::spec::base::nto_qnx; -use crate::spec::{RustcAbi, StackProbeType, Target, TargetOptions, base}; +use crate::spec::{Arch, RustcAbi, StackProbeType, Target, TargetOptions, base}; pub(crate) fn target() -> Target { let mut meta = nto_qnx::meta(); @@ -12,7 +12,7 @@ pub(crate) fn target() -> Target { data_layout: "e-m:e-p:32:32-p270:32:32-p271:32:32-p272:64:64-\ i128:128-f64:32:64-f80:32-n8:16:32-S128" .into(), - arch: "x86".into(), + arch: Arch::X86, options: TargetOptions { rustc_abi: Some(RustcAbi::X86Sse2), cpu: "pentium4".into(), diff --git a/compiler/rustc_target/src/spec/targets/i686_pc_windows_gnu.rs b/compiler/rustc_target/src/spec/targets/i686_pc_windows_gnu.rs index a0d403bd05e69..8ec160748615f 100644 --- a/compiler/rustc_target/src/spec/targets/i686_pc_windows_gnu.rs +++ b/compiler/rustc_target/src/spec/targets/i686_pc_windows_gnu.rs @@ -1,5 +1,5 @@ use crate::spec::{ - Cc, FramePointer, LinkerFlavor, Lld, RustcAbi, Target, TargetMetadata, base, crt_objects, + Arch, Cc, FramePointer, LinkerFlavor, Lld, RustcAbi, Target, TargetMetadata, base, crt_objects, }; pub(crate) fn target() -> Target { @@ -34,7 +34,7 @@ pub(crate) fn target() -> Target { data_layout: "e-m:x-p:32:32-p270:32:32-p271:32:32-p272:64:64-\ i64:64-i128:128-f80:32-n8:16:32-a:0:32-S32" .into(), - arch: "x86".into(), + arch: Arch::X86, options: base, } } diff --git a/compiler/rustc_target/src/spec/targets/i686_pc_windows_gnullvm.rs b/compiler/rustc_target/src/spec/targets/i686_pc_windows_gnullvm.rs index 2e2ea8f81be0f..7893fc771a477 100644 --- a/compiler/rustc_target/src/spec/targets/i686_pc_windows_gnullvm.rs +++ b/compiler/rustc_target/src/spec/targets/i686_pc_windows_gnullvm.rs @@ -1,4 +1,6 @@ -use crate::spec::{Cc, FramePointer, LinkerFlavor, Lld, RustcAbi, Target, TargetMetadata, base}; +use crate::spec::{ + Arch, Cc, FramePointer, LinkerFlavor, Lld, RustcAbi, Target, TargetMetadata, base, +}; pub(crate) fn target() -> Target { let mut base = base::windows_gnullvm::opts(); @@ -27,7 +29,7 @@ pub(crate) fn target() -> Target { data_layout: "e-m:x-p:32:32-p270:32:32-p271:32:32-p272:64:64-\ i64:64-i128:128-f80:32-n8:16:32-a:0:32-S32" .into(), - arch: "x86".into(), + arch: Arch::X86, options: base, } } diff --git a/compiler/rustc_target/src/spec/targets/i686_pc_windows_msvc.rs b/compiler/rustc_target/src/spec/targets/i686_pc_windows_msvc.rs index 6a95afa1d0d3c..8f2746c461661 100644 --- a/compiler/rustc_target/src/spec/targets/i686_pc_windows_msvc.rs +++ b/compiler/rustc_target/src/spec/targets/i686_pc_windows_msvc.rs @@ -1,4 +1,4 @@ -use crate::spec::{LinkerFlavor, Lld, RustcAbi, SanitizerSet, Target, TargetMetadata, base}; +use crate::spec::{Arch, LinkerFlavor, Lld, RustcAbi, SanitizerSet, Target, TargetMetadata, base}; pub(crate) fn target() -> Target { let mut base = base::windows_msvc::opts(); @@ -32,7 +32,7 @@ pub(crate) fn target() -> Target { data_layout: "e-m:x-p:32:32-p270:32:32-p271:32:32-p272:64:64-\ i64:64-i128:128-f80:128-n8:16:32-a:0:32-S32" .into(), - arch: "x86".into(), + arch: Arch::X86, options: base, } } diff --git a/compiler/rustc_target/src/spec/targets/i686_unknown_freebsd.rs b/compiler/rustc_target/src/spec/targets/i686_unknown_freebsd.rs index 1dfea64ebed62..6ff5f6d96b849 100644 --- a/compiler/rustc_target/src/spec/targets/i686_unknown_freebsd.rs +++ b/compiler/rustc_target/src/spec/targets/i686_unknown_freebsd.rs @@ -1,4 +1,6 @@ -use crate::spec::{Cc, LinkerFlavor, Lld, RustcAbi, StackProbeType, Target, TargetMetadata, base}; +use crate::spec::{ + Arch, Cc, LinkerFlavor, Lld, RustcAbi, StackProbeType, Target, TargetMetadata, base, +}; pub(crate) fn target() -> Target { let mut base = base::freebsd::opts(); @@ -20,7 +22,7 @@ pub(crate) fn target() -> Target { data_layout: "e-m:e-p:32:32-p270:32:32-p271:32:32-p272:64:64-\ i128:128-f64:32:64-f80:32-n8:16:32-S128" .into(), - arch: "x86".into(), + arch: Arch::X86, options: base, } } diff --git a/compiler/rustc_target/src/spec/targets/i686_unknown_haiku.rs b/compiler/rustc_target/src/spec/targets/i686_unknown_haiku.rs index ab329170a4f3b..a5d4be426897e 100644 --- a/compiler/rustc_target/src/spec/targets/i686_unknown_haiku.rs +++ b/compiler/rustc_target/src/spec/targets/i686_unknown_haiku.rs @@ -1,4 +1,6 @@ -use crate::spec::{Cc, LinkerFlavor, Lld, RustcAbi, StackProbeType, Target, TargetMetadata, base}; +use crate::spec::{ + Arch, Cc, LinkerFlavor, Lld, RustcAbi, StackProbeType, Target, TargetMetadata, base, +}; pub(crate) fn target() -> Target { let mut base = base::haiku::opts(); @@ -20,7 +22,7 @@ pub(crate) fn target() -> Target { data_layout: "e-m:e-p:32:32-p270:32:32-p271:32:32-p272:64:64-\ i128:128-f64:32:64-f80:32-n8:16:32-S128" .into(), - arch: "x86".into(), + arch: Arch::X86, options: base, } } diff --git a/compiler/rustc_target/src/spec/targets/i686_unknown_helenos.rs b/compiler/rustc_target/src/spec/targets/i686_unknown_helenos.rs index 1cd32d6f78d93..c653f434fc708 100644 --- a/compiler/rustc_target/src/spec/targets/i686_unknown_helenos.rs +++ b/compiler/rustc_target/src/spec/targets/i686_unknown_helenos.rs @@ -1,4 +1,4 @@ -use crate::spec::{Cc, LinkerFlavor, Lld, RustcAbi, Target, base}; +use crate::spec::{Arch, Cc, LinkerFlavor, Lld, RustcAbi, Target, base}; pub(crate) fn target() -> Target { let mut base = base::helenos::opts(); @@ -20,7 +20,7 @@ pub(crate) fn target() -> Target { data_layout: "e-m:e-p:32:32-p270:32:32-p271:32:32-p272:64:64-\ i128:128-f64:32:64-f80:32-n8:16:32-S128" .into(), - arch: "x86".into(), + arch: Arch::X86, options: base, } } diff --git a/compiler/rustc_target/src/spec/targets/i686_unknown_hurd_gnu.rs b/compiler/rustc_target/src/spec/targets/i686_unknown_hurd_gnu.rs index b01f93f74042c..cf65bdd6decfc 100644 --- a/compiler/rustc_target/src/spec/targets/i686_unknown_hurd_gnu.rs +++ b/compiler/rustc_target/src/spec/targets/i686_unknown_hurd_gnu.rs @@ -1,4 +1,4 @@ -use crate::spec::{Cc, LinkerFlavor, Lld, StackProbeType, Target, TargetMetadata, base}; +use crate::spec::{Arch, Cc, LinkerFlavor, Lld, StackProbeType, Target, TargetMetadata, base}; pub(crate) fn target() -> Target { let mut base = base::hurd_gnu::opts(); @@ -19,7 +19,7 @@ pub(crate) fn target() -> Target { data_layout: "e-m:e-p:32:32-p270:32:32-p271:32:32-p272:64:64-\ i128:128-f64:32:64-f80:32-n8:16:32-S128" .into(), - arch: "x86".into(), + arch: Arch::X86, options: base, } } diff --git a/compiler/rustc_target/src/spec/targets/i686_unknown_linux_gnu.rs b/compiler/rustc_target/src/spec/targets/i686_unknown_linux_gnu.rs index c70c026f9f71e..932f6034433e5 100644 --- a/compiler/rustc_target/src/spec/targets/i686_unknown_linux_gnu.rs +++ b/compiler/rustc_target/src/spec/targets/i686_unknown_linux_gnu.rs @@ -1,5 +1,6 @@ use crate::spec::{ - Cc, LinkerFlavor, Lld, RustcAbi, SanitizerSet, StackProbeType, Target, TargetMetadata, base, + Arch, Cc, LinkerFlavor, Lld, RustcAbi, SanitizerSet, StackProbeType, Target, TargetMetadata, + base, }; pub(crate) fn target() -> Target { @@ -34,7 +35,7 @@ pub(crate) fn target() -> Target { data_layout: "e-m:e-p:32:32-p270:32:32-p271:32:32-p272:64:64-\ i128:128-f64:32:64-f80:32-n8:16:32-S128" .into(), - arch: "x86".into(), + arch: Arch::X86, options: base, } } diff --git a/compiler/rustc_target/src/spec/targets/i686_unknown_linux_musl.rs b/compiler/rustc_target/src/spec/targets/i686_unknown_linux_musl.rs index b6b85f5236d80..5c85a3e13820c 100644 --- a/compiler/rustc_target/src/spec/targets/i686_unknown_linux_musl.rs +++ b/compiler/rustc_target/src/spec/targets/i686_unknown_linux_musl.rs @@ -1,5 +1,6 @@ use crate::spec::{ - Cc, FramePointer, LinkerFlavor, Lld, RustcAbi, StackProbeType, Target, TargetMetadata, base, + Arch, Cc, FramePointer, LinkerFlavor, Lld, RustcAbi, StackProbeType, Target, TargetMetadata, + base, }; pub(crate) fn target() -> Target { @@ -40,7 +41,7 @@ pub(crate) fn target() -> Target { data_layout: "e-m:e-p:32:32-p270:32:32-p271:32:32-p272:64:64-\ i128:128-f64:32:64-f80:32-n8:16:32-S128" .into(), - arch: "x86".into(), + arch: Arch::X86, options: base, } } diff --git a/compiler/rustc_target/src/spec/targets/i686_unknown_netbsd.rs b/compiler/rustc_target/src/spec/targets/i686_unknown_netbsd.rs index cbd61cadb3603..8cecc2badf117 100644 --- a/compiler/rustc_target/src/spec/targets/i686_unknown_netbsd.rs +++ b/compiler/rustc_target/src/spec/targets/i686_unknown_netbsd.rs @@ -1,5 +1,6 @@ use crate::spec::{ - Cc, LinkerFlavor, Lld, RustcAbi, StackProbeType, Target, TargetMetadata, TargetOptions, base, + Arch, Cc, LinkerFlavor, Lld, RustcAbi, StackProbeType, Target, TargetMetadata, TargetOptions, + base, }; pub(crate) fn target() -> Target { @@ -22,7 +23,7 @@ pub(crate) fn target() -> Target { data_layout: "e-m:e-p:32:32-p270:32:32-p271:32:32-p272:64:64-\ i128:128-f64:32:64-f80:32-n8:16:32-S128" .into(), - arch: "x86".into(), + arch: Arch::X86, options: TargetOptions { mcount: "__mcount".into(), ..base }, } } diff --git a/compiler/rustc_target/src/spec/targets/i686_unknown_openbsd.rs b/compiler/rustc_target/src/spec/targets/i686_unknown_openbsd.rs index 48f7be7dc2b53..572dedb3d30c3 100644 --- a/compiler/rustc_target/src/spec/targets/i686_unknown_openbsd.rs +++ b/compiler/rustc_target/src/spec/targets/i686_unknown_openbsd.rs @@ -1,4 +1,6 @@ -use crate::spec::{Cc, LinkerFlavor, Lld, RustcAbi, StackProbeType, Target, TargetMetadata, base}; +use crate::spec::{ + Arch, Cc, LinkerFlavor, Lld, RustcAbi, StackProbeType, Target, TargetMetadata, base, +}; pub(crate) fn target() -> Target { let mut base = base::openbsd::opts(); @@ -20,7 +22,7 @@ pub(crate) fn target() -> Target { data_layout: "e-m:e-p:32:32-p270:32:32-p271:32:32-p272:64:64-\ i128:128-f64:32:64-f80:32-n8:16:32-S128" .into(), - arch: "x86".into(), + arch: Arch::X86, options: base, } } diff --git a/compiler/rustc_target/src/spec/targets/i686_unknown_uefi.rs b/compiler/rustc_target/src/spec/targets/i686_unknown_uefi.rs index 1a7923ca89bd2..37b202097b467 100644 --- a/compiler/rustc_target/src/spec/targets/i686_unknown_uefi.rs +++ b/compiler/rustc_target/src/spec/targets/i686_unknown_uefi.rs @@ -5,7 +5,7 @@ // The cdecl ABI is used. It differs from the stdcall or fastcall ABI. // "i686-unknown-windows" is used to get the minimal subset of windows-specific features. -use crate::spec::{LinkerFlavor, Lld, RustcAbi, Target, TargetMetadata, add_link_args, base}; +use crate::spec::{Arch, LinkerFlavor, Lld, RustcAbi, Target, TargetMetadata, add_link_args, base}; pub(crate) fn target() -> Target { let mut base = base::uefi_msvc::opts(); @@ -96,7 +96,7 @@ pub(crate) fn target() -> Target { data_layout: "e-m:x-p:32:32-p270:32:32-p271:32:32-p272:64:64-\ i64:64-i128:128-f80:32-n8:16:32-a:0:32-S32" .into(), - arch: "x86".into(), + arch: Arch::X86, options: base, } diff --git a/compiler/rustc_target/src/spec/targets/i686_uwp_windows_gnu.rs b/compiler/rustc_target/src/spec/targets/i686_uwp_windows_gnu.rs index d95f779774f13..bf2608f8aa77f 100644 --- a/compiler/rustc_target/src/spec/targets/i686_uwp_windows_gnu.rs +++ b/compiler/rustc_target/src/spec/targets/i686_uwp_windows_gnu.rs @@ -1,4 +1,6 @@ -use crate::spec::{Cc, FramePointer, LinkerFlavor, Lld, RustcAbi, Target, TargetMetadata, base}; +use crate::spec::{ + Arch, Cc, FramePointer, LinkerFlavor, Lld, RustcAbi, Target, TargetMetadata, base, +}; pub(crate) fn target() -> Target { let mut base = base::windows_uwp_gnu::opts(); @@ -27,7 +29,7 @@ pub(crate) fn target() -> Target { data_layout: "e-m:x-p:32:32-p270:32:32-p271:32:32-p272:64:64-\ i64:64-i128:128-f80:32-n8:16:32-a:0:32-S32" .into(), - arch: "x86".into(), + arch: Arch::X86, options: base, } } diff --git a/compiler/rustc_target/src/spec/targets/i686_uwp_windows_msvc.rs b/compiler/rustc_target/src/spec/targets/i686_uwp_windows_msvc.rs index fa7a103df797f..e6d2916d11099 100644 --- a/compiler/rustc_target/src/spec/targets/i686_uwp_windows_msvc.rs +++ b/compiler/rustc_target/src/spec/targets/i686_uwp_windows_msvc.rs @@ -1,4 +1,4 @@ -use crate::spec::{RustcAbi, Target, TargetMetadata, base}; +use crate::spec::{Arch, RustcAbi, Target, TargetMetadata, base}; pub(crate) fn target() -> Target { let mut base = base::windows_uwp_msvc::opts(); @@ -18,7 +18,7 @@ pub(crate) fn target() -> Target { data_layout: "e-m:x-p:32:32-p270:32:32-p271:32:32-p272:64:64-\ i64:64-i128:128-f80:128-n8:16:32-a:0:32-S32" .into(), - arch: "x86".into(), + arch: Arch::X86, options: base, } } diff --git a/compiler/rustc_target/src/spec/targets/i686_win7_windows_gnu.rs b/compiler/rustc_target/src/spec/targets/i686_win7_windows_gnu.rs index f364c2cb03276..c026f915906cb 100644 --- a/compiler/rustc_target/src/spec/targets/i686_win7_windows_gnu.rs +++ b/compiler/rustc_target/src/spec/targets/i686_win7_windows_gnu.rs @@ -1,4 +1,6 @@ -use crate::spec::{Cc, FramePointer, LinkerFlavor, Lld, RustcAbi, Target, TargetMetadata, base}; +use crate::spec::{ + Arch, Cc, FramePointer, LinkerFlavor, Lld, RustcAbi, Target, TargetMetadata, base, +}; pub(crate) fn target() -> Target { let mut base = base::windows_gnu::opts(); @@ -29,7 +31,7 @@ pub(crate) fn target() -> Target { data_layout: "e-m:x-p:32:32-p270:32:32-p271:32:32-p272:64:64-\ i64:64-i128:128-f80:32-n8:16:32-a:0:32-S32" .into(), - arch: "x86".into(), + arch: Arch::X86, options: base, } } diff --git a/compiler/rustc_target/src/spec/targets/i686_win7_windows_msvc.rs b/compiler/rustc_target/src/spec/targets/i686_win7_windows_msvc.rs index 91ab311109787..68131bf654264 100644 --- a/compiler/rustc_target/src/spec/targets/i686_win7_windows_msvc.rs +++ b/compiler/rustc_target/src/spec/targets/i686_win7_windows_msvc.rs @@ -1,4 +1,4 @@ -use crate::spec::{LinkerFlavor, Lld, RustcAbi, SanitizerSet, Target, TargetMetadata, base}; +use crate::spec::{Arch, LinkerFlavor, Lld, RustcAbi, SanitizerSet, Target, TargetMetadata, base}; pub(crate) fn target() -> Target { let mut base = base::windows_msvc::opts(); @@ -39,7 +39,7 @@ pub(crate) fn target() -> Target { data_layout: "e-m:x-p:32:32-p270:32:32-p271:32:32-p272:64:64-\ i64:64-i128:128-f80:128-n8:16:32-a:0:32-S32" .into(), - arch: "x86".into(), + arch: Arch::X86, options: base, } } diff --git a/compiler/rustc_target/src/spec/targets/i686_wrs_vxworks.rs b/compiler/rustc_target/src/spec/targets/i686_wrs_vxworks.rs index 63ede7b4ab897..9ce61da7f9501 100644 --- a/compiler/rustc_target/src/spec/targets/i686_wrs_vxworks.rs +++ b/compiler/rustc_target/src/spec/targets/i686_wrs_vxworks.rs @@ -1,4 +1,6 @@ -use crate::spec::{Cc, LinkerFlavor, Lld, RustcAbi, StackProbeType, Target, TargetMetadata, base}; +use crate::spec::{ + Arch, Cc, LinkerFlavor, Lld, RustcAbi, StackProbeType, Target, TargetMetadata, base, +}; pub(crate) fn target() -> Target { let mut base = base::vxworks::opts(); @@ -20,7 +22,7 @@ pub(crate) fn target() -> Target { data_layout: "e-m:e-p:32:32-p270:32:32-p271:32:32-p272:64:64-\ i128:128-f64:32:64-f80:32-n8:16:32-S128" .into(), - arch: "x86".into(), + arch: Arch::X86, options: base, } } diff --git a/compiler/rustc_target/src/spec/targets/loongarch32_unknown_none.rs b/compiler/rustc_target/src/spec/targets/loongarch32_unknown_none.rs index fb4963b88b0f4..d9a4708a9c2d5 100644 --- a/compiler/rustc_target/src/spec/targets/loongarch32_unknown_none.rs +++ b/compiler/rustc_target/src/spec/targets/loongarch32_unknown_none.rs @@ -1,5 +1,5 @@ use crate::spec::{ - Cc, LinkerFlavor, Lld, PanicStrategy, RelocModel, Target, TargetMetadata, TargetOptions, + Arch, Cc, LinkerFlavor, Lld, PanicStrategy, RelocModel, Target, TargetMetadata, TargetOptions, }; pub(crate) fn target() -> Target { @@ -13,7 +13,7 @@ pub(crate) fn target() -> Target { }, pointer_width: 32, data_layout: "e-m:e-p:32:32-i64:64-n32-S128".into(), - arch: "loongarch32".into(), + arch: Arch::LoongArch32, options: TargetOptions { cpu: "generic".into(), features: "+f,+d".into(), diff --git a/compiler/rustc_target/src/spec/targets/loongarch32_unknown_none_softfloat.rs b/compiler/rustc_target/src/spec/targets/loongarch32_unknown_none_softfloat.rs index 0e65f83a71cff..4ac9241fb8c68 100644 --- a/compiler/rustc_target/src/spec/targets/loongarch32_unknown_none_softfloat.rs +++ b/compiler/rustc_target/src/spec/targets/loongarch32_unknown_none_softfloat.rs @@ -1,5 +1,5 @@ use crate::spec::{ - Cc, LinkerFlavor, Lld, PanicStrategy, RelocModel, Target, TargetMetadata, TargetOptions, + Arch, Cc, LinkerFlavor, Lld, PanicStrategy, RelocModel, Target, TargetMetadata, TargetOptions, }; pub(crate) fn target() -> Target { @@ -13,7 +13,7 @@ pub(crate) fn target() -> Target { }, pointer_width: 32, data_layout: "e-m:e-p:32:32-i64:64-n32-S128".into(), - arch: "loongarch32".into(), + arch: Arch::LoongArch32, options: TargetOptions { cpu: "generic".into(), features: "-f,-d".into(), diff --git a/compiler/rustc_target/src/spec/targets/loongarch64_unknown_linux_gnu.rs b/compiler/rustc_target/src/spec/targets/loongarch64_unknown_linux_gnu.rs index 9e743a355296c..255756b5b4f17 100644 --- a/compiler/rustc_target/src/spec/targets/loongarch64_unknown_linux_gnu.rs +++ b/compiler/rustc_target/src/spec/targets/loongarch64_unknown_linux_gnu.rs @@ -1,4 +1,4 @@ -use crate::spec::{CodeModel, SanitizerSet, Target, TargetMetadata, TargetOptions, base}; +use crate::spec::{Arch, CodeModel, SanitizerSet, Target, TargetMetadata, TargetOptions, base}; pub(crate) fn target() -> Target { Target { @@ -11,7 +11,7 @@ pub(crate) fn target() -> Target { }, pointer_width: 64, data_layout: "e-m:e-p:64:64-i64:64-i128:128-n32:64-S128".into(), - arch: "loongarch64".into(), + arch: Arch::LoongArch64, options: TargetOptions { code_model: Some(CodeModel::Medium), cpu: "generic".into(), diff --git a/compiler/rustc_target/src/spec/targets/loongarch64_unknown_linux_musl.rs b/compiler/rustc_target/src/spec/targets/loongarch64_unknown_linux_musl.rs index d9010b1e4eebc..74b0efd63e775 100644 --- a/compiler/rustc_target/src/spec/targets/loongarch64_unknown_linux_musl.rs +++ b/compiler/rustc_target/src/spec/targets/loongarch64_unknown_linux_musl.rs @@ -1,4 +1,4 @@ -use crate::spec::{CodeModel, SanitizerSet, Target, TargetMetadata, TargetOptions, base}; +use crate::spec::{Arch, CodeModel, SanitizerSet, Target, TargetMetadata, TargetOptions, base}; pub(crate) fn target() -> Target { Target { @@ -11,7 +11,7 @@ pub(crate) fn target() -> Target { }, pointer_width: 64, data_layout: "e-m:e-p:64:64-i64:64-i128:128-n32:64-S128".into(), - arch: "loongarch64".into(), + arch: Arch::LoongArch64, options: TargetOptions { code_model: Some(CodeModel::Medium), cpu: "generic".into(), diff --git a/compiler/rustc_target/src/spec/targets/loongarch64_unknown_linux_ohos.rs b/compiler/rustc_target/src/spec/targets/loongarch64_unknown_linux_ohos.rs index c1c859ef25c81..222cf5c92c561 100644 --- a/compiler/rustc_target/src/spec/targets/loongarch64_unknown_linux_ohos.rs +++ b/compiler/rustc_target/src/spec/targets/loongarch64_unknown_linux_ohos.rs @@ -1,4 +1,4 @@ -use crate::spec::{CodeModel, SanitizerSet, Target, TargetMetadata, TargetOptions, base}; +use crate::spec::{Arch, CodeModel, SanitizerSet, Target, TargetMetadata, TargetOptions, base}; pub(crate) fn target() -> Target { Target { @@ -11,7 +11,7 @@ pub(crate) fn target() -> Target { }, pointer_width: 64, data_layout: "e-m:e-p:64:64-i64:64-i128:128-n32:64-S128".into(), - arch: "loongarch64".into(), + arch: Arch::LoongArch64, options: TargetOptions { code_model: Some(CodeModel::Medium), cpu: "generic".into(), diff --git a/compiler/rustc_target/src/spec/targets/loongarch64_unknown_none.rs b/compiler/rustc_target/src/spec/targets/loongarch64_unknown_none.rs index b6a08958284fa..d8b5095820179 100644 --- a/compiler/rustc_target/src/spec/targets/loongarch64_unknown_none.rs +++ b/compiler/rustc_target/src/spec/targets/loongarch64_unknown_none.rs @@ -1,5 +1,5 @@ use crate::spec::{ - Cc, CodeModel, LinkerFlavor, Lld, PanicStrategy, RelocModel, Target, TargetMetadata, + Arch, Cc, CodeModel, LinkerFlavor, Lld, PanicStrategy, RelocModel, Target, TargetMetadata, TargetOptions, }; @@ -14,7 +14,7 @@ pub(crate) fn target() -> Target { }, pointer_width: 64, data_layout: "e-m:e-p:64:64-i64:64-i128:128-n32:64-S128".into(), - arch: "loongarch64".into(), + arch: Arch::LoongArch64, options: TargetOptions { cpu: "generic".into(), features: "+f,+d,-lsx".into(), diff --git a/compiler/rustc_target/src/spec/targets/loongarch64_unknown_none_softfloat.rs b/compiler/rustc_target/src/spec/targets/loongarch64_unknown_none_softfloat.rs index 24983900683e3..e33d8c954fd08 100644 --- a/compiler/rustc_target/src/spec/targets/loongarch64_unknown_none_softfloat.rs +++ b/compiler/rustc_target/src/spec/targets/loongarch64_unknown_none_softfloat.rs @@ -1,5 +1,5 @@ use crate::spec::{ - Cc, CodeModel, LinkerFlavor, Lld, PanicStrategy, RelocModel, Target, TargetMetadata, + Arch, Cc, CodeModel, LinkerFlavor, Lld, PanicStrategy, RelocModel, Target, TargetMetadata, TargetOptions, }; @@ -14,7 +14,7 @@ pub(crate) fn target() -> Target { }, pointer_width: 64, data_layout: "e-m:e-p:64:64-i64:64-i128:128-n32:64-S128".into(), - arch: "loongarch64".into(), + arch: Arch::LoongArch64, options: TargetOptions { cpu: "generic".into(), features: "-f,-d".into(), diff --git a/compiler/rustc_target/src/spec/targets/m68k_unknown_linux_gnu.rs b/compiler/rustc_target/src/spec/targets/m68k_unknown_linux_gnu.rs index 9bd02e842c243..75bb02c25112b 100644 --- a/compiler/rustc_target/src/spec/targets/m68k_unknown_linux_gnu.rs +++ b/compiler/rustc_target/src/spec/targets/m68k_unknown_linux_gnu.rs @@ -1,6 +1,6 @@ use rustc_abi::Endian; -use crate::spec::{LinkSelfContainedDefault, Target, TargetMetadata, TargetOptions, base}; +use crate::spec::{Arch, LinkSelfContainedDefault, Target, TargetMetadata, TargetOptions, base}; pub(crate) fn target() -> Target { let mut base = base::linux_gnu::opts(); @@ -17,7 +17,7 @@ pub(crate) fn target() -> Target { }, pointer_width: 32, data_layout: "E-m:e-p:32:16:32-i8:8:8-i16:16:16-i32:16:32-n8:16:32-a:0:16-S16".into(), - arch: "m68k".into(), + arch: Arch::M68k, options: TargetOptions { endian: Endian::Big, mcount: "_mcount".into(), diff --git a/compiler/rustc_target/src/spec/targets/m68k_unknown_none_elf.rs b/compiler/rustc_target/src/spec/targets/m68k_unknown_none_elf.rs index 6b66052692a4a..56869348df852 100644 --- a/compiler/rustc_target/src/spec/targets/m68k_unknown_none_elf.rs +++ b/compiler/rustc_target/src/spec/targets/m68k_unknown_none_elf.rs @@ -1,6 +1,8 @@ use rustc_abi::Endian; -use crate::spec::{CodeModel, PanicStrategy, RelocModel, Target, TargetMetadata, TargetOptions}; +use crate::spec::{ + Arch, CodeModel, PanicStrategy, RelocModel, Target, TargetMetadata, TargetOptions, +}; pub(crate) fn target() -> Target { let options = TargetOptions { @@ -28,7 +30,7 @@ pub(crate) fn target() -> Target { }, pointer_width: 32, data_layout: "E-m:e-p:32:16:32-i8:8:8-i16:16:16-i32:16:32-n8:16:32-a:0:16-S16".into(), - arch: "m68k".into(), + arch: Arch::M68k, options, } } diff --git a/compiler/rustc_target/src/spec/targets/mips64_openwrt_linux_musl.rs b/compiler/rustc_target/src/spec/targets/mips64_openwrt_linux_musl.rs index eb1148d5e8fa1..0cd93429f6e27 100644 --- a/compiler/rustc_target/src/spec/targets/mips64_openwrt_linux_musl.rs +++ b/compiler/rustc_target/src/spec/targets/mips64_openwrt_linux_musl.rs @@ -2,7 +2,7 @@ use rustc_abi::Endian; -use crate::spec::{Target, TargetMetadata, TargetOptions, base}; +use crate::spec::{Arch, Target, TargetMetadata, TargetOptions, base}; pub(crate) fn target() -> Target { let mut base = base::linux_musl::opts(); @@ -21,7 +21,7 @@ pub(crate) fn target() -> Target { }, pointer_width: 64, data_layout: "E-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128".into(), - arch: "mips64".into(), + arch: Arch::Mips64, options: TargetOptions { vendor: "openwrt".into(), abi: "abi64".into(), diff --git a/compiler/rustc_target/src/spec/targets/mips64_unknown_linux_gnuabi64.rs b/compiler/rustc_target/src/spec/targets/mips64_unknown_linux_gnuabi64.rs index a26350ff22509..4d06466e6553f 100644 --- a/compiler/rustc_target/src/spec/targets/mips64_unknown_linux_gnuabi64.rs +++ b/compiler/rustc_target/src/spec/targets/mips64_unknown_linux_gnuabi64.rs @@ -1,6 +1,6 @@ use rustc_abi::Endian; -use crate::spec::{Target, TargetMetadata, TargetOptions, base}; +use crate::spec::{Arch, Target, TargetMetadata, TargetOptions, base}; pub(crate) fn target() -> Target { Target { @@ -13,7 +13,7 @@ pub(crate) fn target() -> Target { }, pointer_width: 64, data_layout: "E-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128".into(), - arch: "mips64".into(), + arch: Arch::Mips64, options: TargetOptions { abi: "abi64".into(), endian: Endian::Big, diff --git a/compiler/rustc_target/src/spec/targets/mips64_unknown_linux_muslabi64.rs b/compiler/rustc_target/src/spec/targets/mips64_unknown_linux_muslabi64.rs index e54628acb1ad2..a37508c34dbd9 100644 --- a/compiler/rustc_target/src/spec/targets/mips64_unknown_linux_muslabi64.rs +++ b/compiler/rustc_target/src/spec/targets/mips64_unknown_linux_muslabi64.rs @@ -1,6 +1,6 @@ use rustc_abi::Endian; -use crate::spec::{Target, TargetMetadata, TargetOptions, base}; +use crate::spec::{Arch, Target, TargetMetadata, TargetOptions, base}; pub(crate) fn target() -> Target { let mut base = base::linux_musl::opts(); @@ -18,7 +18,7 @@ pub(crate) fn target() -> Target { }, pointer_width: 64, data_layout: "E-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128".into(), - arch: "mips64".into(), + arch: Arch::Mips64, options: TargetOptions { abi: "abi64".into(), endian: Endian::Big, diff --git a/compiler/rustc_target/src/spec/targets/mips64el_unknown_linux_gnuabi64.rs b/compiler/rustc_target/src/spec/targets/mips64el_unknown_linux_gnuabi64.rs index 19bceadc62232..9ece84ed54428 100644 --- a/compiler/rustc_target/src/spec/targets/mips64el_unknown_linux_gnuabi64.rs +++ b/compiler/rustc_target/src/spec/targets/mips64el_unknown_linux_gnuabi64.rs @@ -1,4 +1,4 @@ -use crate::spec::{Target, TargetMetadata, TargetOptions, base}; +use crate::spec::{Arch, Target, TargetMetadata, TargetOptions, base}; pub(crate) fn target() -> Target { Target { @@ -11,7 +11,7 @@ pub(crate) fn target() -> Target { }, pointer_width: 64, data_layout: "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128".into(), - arch: "mips64".into(), + arch: Arch::Mips64, options: TargetOptions { abi: "abi64".into(), // NOTE(mips64r2) matches C toolchain diff --git a/compiler/rustc_target/src/spec/targets/mips64el_unknown_linux_muslabi64.rs b/compiler/rustc_target/src/spec/targets/mips64el_unknown_linux_muslabi64.rs index a256733734f7f..759a04d24b7c9 100644 --- a/compiler/rustc_target/src/spec/targets/mips64el_unknown_linux_muslabi64.rs +++ b/compiler/rustc_target/src/spec/targets/mips64el_unknown_linux_muslabi64.rs @@ -1,4 +1,4 @@ -use crate::spec::{Target, TargetMetadata, TargetOptions, base}; +use crate::spec::{Arch, Target, TargetMetadata, TargetOptions, base}; pub(crate) fn target() -> Target { let mut base = base::linux_musl::opts(); @@ -16,7 +16,7 @@ pub(crate) fn target() -> Target { }, pointer_width: 64, data_layout: "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128".into(), - arch: "mips64".into(), + arch: Arch::Mips64, options: TargetOptions { abi: "abi64".into(), mcount: "_mcount".into(), diff --git a/compiler/rustc_target/src/spec/targets/mips_mti_none_elf.rs b/compiler/rustc_target/src/spec/targets/mips_mti_none_elf.rs index def12122416a9..54039925e7957 100644 --- a/compiler/rustc_target/src/spec/targets/mips_mti_none_elf.rs +++ b/compiler/rustc_target/src/spec/targets/mips_mti_none_elf.rs @@ -1,7 +1,7 @@ use rustc_abi::Endian; use crate::spec::{ - Cc, LinkerFlavor, Lld, PanicStrategy, RelocModel, Target, TargetMetadata, TargetOptions, + Arch, Cc, LinkerFlavor, Lld, PanicStrategy, RelocModel, Target, TargetMetadata, TargetOptions, }; pub(crate) fn target() -> Target { @@ -15,7 +15,7 @@ pub(crate) fn target() -> Target { std: None, // ? }, pointer_width: 32, - arch: "mips".into(), + arch: Arch::Mips, options: TargetOptions { vendor: "mti".into(), diff --git a/compiler/rustc_target/src/spec/targets/mips_unknown_linux_gnu.rs b/compiler/rustc_target/src/spec/targets/mips_unknown_linux_gnu.rs index 29a451b31a659..ea6e237895ae3 100644 --- a/compiler/rustc_target/src/spec/targets/mips_unknown_linux_gnu.rs +++ b/compiler/rustc_target/src/spec/targets/mips_unknown_linux_gnu.rs @@ -1,6 +1,6 @@ use rustc_abi::Endian; -use crate::spec::{Target, TargetMetadata, TargetOptions, base}; +use crate::spec::{Arch, Target, TargetMetadata, TargetOptions, base}; pub(crate) fn target() -> Target { Target { @@ -13,7 +13,7 @@ pub(crate) fn target() -> Target { }, pointer_width: 32, data_layout: "E-m:m-p:32:32-i8:8:32-i16:16:32-i64:64-n32-S64".into(), - arch: "mips".into(), + arch: Arch::Mips, options: TargetOptions { endian: Endian::Big, cpu: "mips32r2".into(), diff --git a/compiler/rustc_target/src/spec/targets/mips_unknown_linux_musl.rs b/compiler/rustc_target/src/spec/targets/mips_unknown_linux_musl.rs index 2d258d7e438ff..ab68c2495b5ac 100644 --- a/compiler/rustc_target/src/spec/targets/mips_unknown_linux_musl.rs +++ b/compiler/rustc_target/src/spec/targets/mips_unknown_linux_musl.rs @@ -1,6 +1,6 @@ use rustc_abi::Endian; -use crate::spec::{Target, TargetMetadata, TargetOptions, base}; +use crate::spec::{Arch, Target, TargetMetadata, TargetOptions, base}; pub(crate) fn target() -> Target { let mut base = base::linux_musl::opts(); @@ -17,7 +17,7 @@ pub(crate) fn target() -> Target { }, pointer_width: 32, data_layout: "E-m:m-p:32:32-i8:8:32-i16:16:32-i64:64-n32-S64".into(), - arch: "mips".into(), + arch: Arch::Mips, options: TargetOptions { endian: Endian::Big, mcount: "_mcount".into(), ..base }, } } diff --git a/compiler/rustc_target/src/spec/targets/mips_unknown_linux_uclibc.rs b/compiler/rustc_target/src/spec/targets/mips_unknown_linux_uclibc.rs index c14bfbf46d21d..c699f7e20b065 100644 --- a/compiler/rustc_target/src/spec/targets/mips_unknown_linux_uclibc.rs +++ b/compiler/rustc_target/src/spec/targets/mips_unknown_linux_uclibc.rs @@ -1,6 +1,6 @@ use rustc_abi::Endian; -use crate::spec::{Target, TargetMetadata, TargetOptions, base}; +use crate::spec::{Arch, Target, TargetMetadata, TargetOptions, base}; pub(crate) fn target() -> Target { Target { @@ -13,7 +13,7 @@ pub(crate) fn target() -> Target { }, pointer_width: 32, data_layout: "E-m:m-p:32:32-i8:8:32-i16:16:32-i64:64-n32-S64".into(), - arch: "mips".into(), + arch: Arch::Mips, options: TargetOptions { endian: Endian::Big, cpu: "mips32r2".into(), diff --git a/compiler/rustc_target/src/spec/targets/mipsel_mti_none_elf.rs b/compiler/rustc_target/src/spec/targets/mipsel_mti_none_elf.rs index cc9c19e4a0b5e..06c4d14be4323 100644 --- a/compiler/rustc_target/src/spec/targets/mipsel_mti_none_elf.rs +++ b/compiler/rustc_target/src/spec/targets/mipsel_mti_none_elf.rs @@ -1,7 +1,7 @@ use rustc_abi::Endian; use crate::spec::{ - Cc, LinkerFlavor, Lld, PanicStrategy, RelocModel, Target, TargetMetadata, TargetOptions, + Arch, Cc, LinkerFlavor, Lld, PanicStrategy, RelocModel, Target, TargetMetadata, TargetOptions, }; pub(crate) fn target() -> Target { @@ -15,7 +15,7 @@ pub(crate) fn target() -> Target { std: None, // ? }, pointer_width: 32, - arch: "mips".into(), + arch: Arch::Mips, options: TargetOptions { vendor: "mti".into(), diff --git a/compiler/rustc_target/src/spec/targets/mipsel_sony_psp.rs b/compiler/rustc_target/src/spec/targets/mipsel_sony_psp.rs index 37ebb3d174b34..200735f4e0fbd 100644 --- a/compiler/rustc_target/src/spec/targets/mipsel_sony_psp.rs +++ b/compiler/rustc_target/src/spec/targets/mipsel_sony_psp.rs @@ -1,4 +1,6 @@ -use crate::spec::{Cc, LinkerFlavor, Lld, RelocModel, Target, TargetMetadata, TargetOptions, cvs}; +use crate::spec::{ + Arch, Cc, LinkerFlavor, Lld, RelocModel, Target, TargetMetadata, TargetOptions, cvs, +}; // The PSP has custom linker requirements. const LINKER_SCRIPT: &str = include_str!("./mipsel_sony_psp_linker_script.ld"); @@ -19,7 +21,7 @@ pub(crate) fn target() -> Target { }, pointer_width: 32, data_layout: "e-m:m-p:32:32-i8:8:32-i16:16:32-i64:64-n32-S64".into(), - arch: "mips".into(), + arch: Arch::Mips, options: TargetOptions { os: "psp".into(), diff --git a/compiler/rustc_target/src/spec/targets/mipsel_sony_psx.rs b/compiler/rustc_target/src/spec/targets/mipsel_sony_psx.rs index 8475a43ea6332..b6d30be589eac 100644 --- a/compiler/rustc_target/src/spec/targets/mipsel_sony_psx.rs +++ b/compiler/rustc_target/src/spec/targets/mipsel_sony_psx.rs @@ -1,5 +1,6 @@ use crate::spec::{ - Cc, LinkerFlavor, Lld, PanicStrategy, RelocModel, Target, TargetMetadata, TargetOptions, cvs, + Arch, Cc, LinkerFlavor, Lld, PanicStrategy, RelocModel, Target, TargetMetadata, TargetOptions, + cvs, }; pub(crate) fn target() -> Target { @@ -13,7 +14,7 @@ pub(crate) fn target() -> Target { }, pointer_width: 32, data_layout: "e-m:m-p:32:32-i8:8:32-i16:16:32-i64:64-n32-S64".into(), - arch: "mips".into(), + arch: Arch::Mips, options: TargetOptions { // The Playstation 1 is mostly bare-metal, but the BIOS does provide some a slight bit diff --git a/compiler/rustc_target/src/spec/targets/mipsel_unknown_linux_gnu.rs b/compiler/rustc_target/src/spec/targets/mipsel_unknown_linux_gnu.rs index 6c7ea5c56889a..79a22e518b0cb 100644 --- a/compiler/rustc_target/src/spec/targets/mipsel_unknown_linux_gnu.rs +++ b/compiler/rustc_target/src/spec/targets/mipsel_unknown_linux_gnu.rs @@ -1,4 +1,4 @@ -use crate::spec::{Target, TargetMetadata, TargetOptions, base}; +use crate::spec::{Arch, Target, TargetMetadata, TargetOptions, base}; pub(crate) fn target() -> Target { Target { @@ -11,7 +11,7 @@ pub(crate) fn target() -> Target { }, pointer_width: 32, data_layout: "e-m:m-p:32:32-i8:8:32-i16:16:32-i64:64-n32-S64".into(), - arch: "mips".into(), + arch: Arch::Mips, options: TargetOptions { cpu: "mips32r2".into(), diff --git a/compiler/rustc_target/src/spec/targets/mipsel_unknown_linux_musl.rs b/compiler/rustc_target/src/spec/targets/mipsel_unknown_linux_musl.rs index f4fb6be332166..8c64b17a37b57 100644 --- a/compiler/rustc_target/src/spec/targets/mipsel_unknown_linux_musl.rs +++ b/compiler/rustc_target/src/spec/targets/mipsel_unknown_linux_musl.rs @@ -1,4 +1,4 @@ -use crate::spec::{Target, TargetMetadata, TargetOptions, base}; +use crate::spec::{Arch, Target, TargetMetadata, TargetOptions, base}; pub(crate) fn target() -> Target { let mut base = base::linux_musl::opts(); @@ -15,7 +15,7 @@ pub(crate) fn target() -> Target { }, pointer_width: 32, data_layout: "e-m:m-p:32:32-i8:8:32-i16:16:32-i64:64-n32-S64".into(), - arch: "mips".into(), + arch: Arch::Mips, options: TargetOptions { mcount: "_mcount".into(), ..base }, } } diff --git a/compiler/rustc_target/src/spec/targets/mipsel_unknown_linux_uclibc.rs b/compiler/rustc_target/src/spec/targets/mipsel_unknown_linux_uclibc.rs index f0056799d66f6..295b1788877ce 100644 --- a/compiler/rustc_target/src/spec/targets/mipsel_unknown_linux_uclibc.rs +++ b/compiler/rustc_target/src/spec/targets/mipsel_unknown_linux_uclibc.rs @@ -1,4 +1,4 @@ -use crate::spec::{Target, TargetMetadata, TargetOptions, base}; +use crate::spec::{Arch, Target, TargetMetadata, TargetOptions, base}; pub(crate) fn target() -> Target { Target { @@ -11,7 +11,7 @@ pub(crate) fn target() -> Target { }, pointer_width: 32, data_layout: "e-m:m-p:32:32-i8:8:32-i16:16:32-i64:64-n32-S64".into(), - arch: "mips".into(), + arch: Arch::Mips, options: TargetOptions { cpu: "mips32r2".into(), diff --git a/compiler/rustc_target/src/spec/targets/mipsel_unknown_netbsd.rs b/compiler/rustc_target/src/spec/targets/mipsel_unknown_netbsd.rs index 502d7382b3cfd..69b232d71ea1e 100644 --- a/compiler/rustc_target/src/spec/targets/mipsel_unknown_netbsd.rs +++ b/compiler/rustc_target/src/spec/targets/mipsel_unknown_netbsd.rs @@ -1,6 +1,6 @@ use rustc_abi::Endian; -use crate::spec::{Target, TargetMetadata, TargetOptions, base}; +use crate::spec::{Arch, Target, TargetMetadata, TargetOptions, base}; pub(crate) fn target() -> Target { let mut base = base::netbsd::opts(); @@ -17,7 +17,7 @@ pub(crate) fn target() -> Target { }, pointer_width: 32, data_layout: "e-m:m-p:32:32-i8:8:32-i16:16:32-i64:64-n32-S64".into(), - arch: "mips".into(), + arch: Arch::Mips, options: TargetOptions { features: "+soft-float".into(), mcount: "__mcount".into(), diff --git a/compiler/rustc_target/src/spec/targets/mipsel_unknown_none.rs b/compiler/rustc_target/src/spec/targets/mipsel_unknown_none.rs index 6a201c56475ee..7012651afc348 100644 --- a/compiler/rustc_target/src/spec/targets/mipsel_unknown_none.rs +++ b/compiler/rustc_target/src/spec/targets/mipsel_unknown_none.rs @@ -3,7 +3,7 @@ //! Can be used for MIPS M4K core (e.g. on PIC32MX devices) use crate::spec::{ - Cc, LinkerFlavor, Lld, PanicStrategy, RelocModel, Target, TargetMetadata, TargetOptions, + Arch, Cc, LinkerFlavor, Lld, PanicStrategy, RelocModel, Target, TargetMetadata, TargetOptions, }; pub(crate) fn target() -> Target { @@ -17,7 +17,7 @@ pub(crate) fn target() -> Target { }, pointer_width: 32, data_layout: "e-m:m-p:32:32-i8:8:32-i16:16:32-i64:64-n32-S64".into(), - arch: "mips".into(), + arch: Arch::Mips, options: TargetOptions { linker_flavor: LinkerFlavor::Gnu(Cc::No, Lld::Yes), diff --git a/compiler/rustc_target/src/spec/targets/mipsisa32r6_unknown_linux_gnu.rs b/compiler/rustc_target/src/spec/targets/mipsisa32r6_unknown_linux_gnu.rs index 0716f2e483b41..b45511446d8d3 100644 --- a/compiler/rustc_target/src/spec/targets/mipsisa32r6_unknown_linux_gnu.rs +++ b/compiler/rustc_target/src/spec/targets/mipsisa32r6_unknown_linux_gnu.rs @@ -1,6 +1,6 @@ use rustc_abi::Endian; -use crate::spec::{Target, TargetMetadata, TargetOptions, base}; +use crate::spec::{Arch, Target, TargetMetadata, TargetOptions, base}; pub(crate) fn target() -> Target { Target { @@ -13,7 +13,7 @@ pub(crate) fn target() -> Target { }, pointer_width: 32, data_layout: "E-m:m-p:32:32-i8:8:32-i16:16:32-i64:64-n32-S64".into(), - arch: "mips32r6".into(), + arch: Arch::Mips32r6, options: TargetOptions { endian: Endian::Big, cpu: "mips32r6".into(), diff --git a/compiler/rustc_target/src/spec/targets/mipsisa32r6el_unknown_linux_gnu.rs b/compiler/rustc_target/src/spec/targets/mipsisa32r6el_unknown_linux_gnu.rs index 81f2424e4dea0..36845029de3b9 100644 --- a/compiler/rustc_target/src/spec/targets/mipsisa32r6el_unknown_linux_gnu.rs +++ b/compiler/rustc_target/src/spec/targets/mipsisa32r6el_unknown_linux_gnu.rs @@ -1,4 +1,4 @@ -use crate::spec::{Target, TargetMetadata, TargetOptions, base}; +use crate::spec::{Arch, Target, TargetMetadata, TargetOptions, base}; pub(crate) fn target() -> Target { Target { @@ -11,7 +11,7 @@ pub(crate) fn target() -> Target { }, pointer_width: 32, data_layout: "e-m:m-p:32:32-i8:8:32-i16:16:32-i64:64-n32-S64".into(), - arch: "mips32r6".into(), + arch: Arch::Mips32r6, options: TargetOptions { cpu: "mips32r6".into(), diff --git a/compiler/rustc_target/src/spec/targets/mipsisa64r6_unknown_linux_gnuabi64.rs b/compiler/rustc_target/src/spec/targets/mipsisa64r6_unknown_linux_gnuabi64.rs index cdd5f6b84365a..3a95f78482bbf 100644 --- a/compiler/rustc_target/src/spec/targets/mipsisa64r6_unknown_linux_gnuabi64.rs +++ b/compiler/rustc_target/src/spec/targets/mipsisa64r6_unknown_linux_gnuabi64.rs @@ -1,6 +1,6 @@ use rustc_abi::Endian; -use crate::spec::{Target, TargetMetadata, TargetOptions, base}; +use crate::spec::{Arch, Target, TargetMetadata, TargetOptions, base}; pub(crate) fn target() -> Target { Target { @@ -13,7 +13,7 @@ pub(crate) fn target() -> Target { }, pointer_width: 64, data_layout: "E-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128".into(), - arch: "mips64r6".into(), + arch: Arch::Mips64r6, options: TargetOptions { abi: "abi64".into(), endian: Endian::Big, diff --git a/compiler/rustc_target/src/spec/targets/mipsisa64r6el_unknown_linux_gnuabi64.rs b/compiler/rustc_target/src/spec/targets/mipsisa64r6el_unknown_linux_gnuabi64.rs index 88879a25818b7..8e5bf3d365594 100644 --- a/compiler/rustc_target/src/spec/targets/mipsisa64r6el_unknown_linux_gnuabi64.rs +++ b/compiler/rustc_target/src/spec/targets/mipsisa64r6el_unknown_linux_gnuabi64.rs @@ -1,4 +1,4 @@ -use crate::spec::{Target, TargetMetadata, TargetOptions, base}; +use crate::spec::{Arch, Target, TargetMetadata, TargetOptions, base}; pub(crate) fn target() -> Target { Target { @@ -11,7 +11,7 @@ pub(crate) fn target() -> Target { }, pointer_width: 64, data_layout: "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128".into(), - arch: "mips64r6".into(), + arch: Arch::Mips64r6, options: TargetOptions { abi: "abi64".into(), // NOTE(mips64r6) matches C toolchain diff --git a/compiler/rustc_target/src/spec/targets/msp430_none_elf.rs b/compiler/rustc_target/src/spec/targets/msp430_none_elf.rs index caf77bb8669d7..d8cee79b69d29 100644 --- a/compiler/rustc_target/src/spec/targets/msp430_none_elf.rs +++ b/compiler/rustc_target/src/spec/targets/msp430_none_elf.rs @@ -1,5 +1,5 @@ use crate::spec::{ - Cc, LinkerFlavor, PanicStrategy, RelocModel, Target, TargetMetadata, TargetOptions, cvs, + Arch, Cc, LinkerFlavor, PanicStrategy, RelocModel, Target, TargetMetadata, TargetOptions, cvs, }; pub(crate) fn target() -> Target { @@ -13,7 +13,7 @@ pub(crate) fn target() -> Target { }, pointer_width: 16, data_layout: "e-m:e-p:16:16-i32:16-i64:16-f32:16-f64:16-a:8-n8:16-S16".into(), - arch: "msp430".into(), + arch: Arch::Msp430, options: TargetOptions { c_int_width: 16, diff --git a/compiler/rustc_target/src/spec/targets/nvptx64_nvidia_cuda.rs b/compiler/rustc_target/src/spec/targets/nvptx64_nvidia_cuda.rs index cada0dd640a49..ac2d31a0d61aa 100644 --- a/compiler/rustc_target/src/spec/targets/nvptx64_nvidia_cuda.rs +++ b/compiler/rustc_target/src/spec/targets/nvptx64_nvidia_cuda.rs @@ -1,11 +1,11 @@ use crate::spec::{ - LinkSelfContainedDefault, LinkerFlavor, MergeFunctions, PanicStrategy, Target, TargetMetadata, - TargetOptions, + Arch, LinkSelfContainedDefault, LinkerFlavor, MergeFunctions, PanicStrategy, Target, + TargetMetadata, TargetOptions, }; pub(crate) fn target() -> Target { Target { - arch: "nvptx64".into(), + arch: Arch::Nvptx64, data_layout: "e-p6:32:32-i64:64-i128:128-i256:256-v16:16-v32:32-n16:32:64".into(), llvm_target: "nvptx64-nvidia-cuda".into(), metadata: TargetMetadata { diff --git a/compiler/rustc_target/src/spec/targets/powerpc64_ibm_aix.rs b/compiler/rustc_target/src/spec/targets/powerpc64_ibm_aix.rs index a140518899970..b4f394643a9dd 100644 --- a/compiler/rustc_target/src/spec/targets/powerpc64_ibm_aix.rs +++ b/compiler/rustc_target/src/spec/targets/powerpc64_ibm_aix.rs @@ -1,4 +1,4 @@ -use crate::spec::{Cc, LinkerFlavor, Target, TargetMetadata, base}; +use crate::spec::{Arch, Cc, LinkerFlavor, Target, TargetMetadata, base}; pub(crate) fn target() -> Target { let mut base = base::aix::opts(); @@ -18,7 +18,7 @@ pub(crate) fn target() -> Target { }, pointer_width: 64, data_layout: "E-m:a-Fi64-i64:64-i128:128-n32:64-S128-v256:256:256-v512:512:512".into(), - arch: "powerpc64".into(), + arch: Arch::PowerPC64, options: base, } } diff --git a/compiler/rustc_target/src/spec/targets/powerpc64_unknown_freebsd.rs b/compiler/rustc_target/src/spec/targets/powerpc64_unknown_freebsd.rs index b01ca989282ef..de94d20234527 100644 --- a/compiler/rustc_target/src/spec/targets/powerpc64_unknown_freebsd.rs +++ b/compiler/rustc_target/src/spec/targets/powerpc64_unknown_freebsd.rs @@ -1,7 +1,7 @@ use rustc_abi::Endian; use crate::spec::{ - Cc, LinkerFlavor, Lld, StackProbeType, Target, TargetMetadata, TargetOptions, base, + Arch, Cc, LinkerFlavor, Lld, StackProbeType, Target, TargetMetadata, TargetOptions, base, }; pub(crate) fn target() -> Target { @@ -23,7 +23,7 @@ pub(crate) fn target() -> Target { }, pointer_width: 64, data_layout: "E-m:e-Fn32-i64:64-i128:128-n32:64".into(), - arch: "powerpc64".into(), + arch: Arch::PowerPC64, options: TargetOptions { endian: Endian::Big, mcount: "_mcount".into(), ..base }, } } diff --git a/compiler/rustc_target/src/spec/targets/powerpc64_unknown_linux_gnu.rs b/compiler/rustc_target/src/spec/targets/powerpc64_unknown_linux_gnu.rs index bc7e445f3f8ae..18a3f059039d1 100644 --- a/compiler/rustc_target/src/spec/targets/powerpc64_unknown_linux_gnu.rs +++ b/compiler/rustc_target/src/spec/targets/powerpc64_unknown_linux_gnu.rs @@ -1,7 +1,7 @@ use rustc_abi::Endian; use crate::spec::{ - Cc, LinkerFlavor, Lld, StackProbeType, Target, TargetMetadata, TargetOptions, base, + Arch, Cc, LinkerFlavor, Lld, StackProbeType, Target, TargetMetadata, TargetOptions, base, }; pub(crate) fn target() -> Target { @@ -23,7 +23,7 @@ pub(crate) fn target() -> Target { }, pointer_width: 64, data_layout: "E-m:e-Fi64-i64:64-i128:128-n32:64-S128-v256:256:256-v512:512:512".into(), - arch: "powerpc64".into(), + arch: Arch::PowerPC64, options: TargetOptions { endian: Endian::Big, mcount: "_mcount".into(), ..base }, } } diff --git a/compiler/rustc_target/src/spec/targets/powerpc64_unknown_linux_musl.rs b/compiler/rustc_target/src/spec/targets/powerpc64_unknown_linux_musl.rs index 8fb991d0bd1a7..64d4f58a46644 100644 --- a/compiler/rustc_target/src/spec/targets/powerpc64_unknown_linux_musl.rs +++ b/compiler/rustc_target/src/spec/targets/powerpc64_unknown_linux_musl.rs @@ -1,7 +1,7 @@ use rustc_abi::Endian; use crate::spec::{ - Cc, LinkerFlavor, Lld, StackProbeType, Target, TargetMetadata, TargetOptions, base, + Arch, Cc, LinkerFlavor, Lld, StackProbeType, Target, TargetMetadata, TargetOptions, base, }; pub(crate) fn target() -> Target { @@ -23,7 +23,7 @@ pub(crate) fn target() -> Target { }, pointer_width: 64, data_layout: "E-m:e-Fn32-i64:64-i128:128-n32:64-S128-v256:256:256-v512:512:512".into(), - arch: "powerpc64".into(), + arch: Arch::PowerPC64, options: TargetOptions { endian: Endian::Big, mcount: "_mcount".into(), ..base }, } } diff --git a/compiler/rustc_target/src/spec/targets/powerpc64_unknown_openbsd.rs b/compiler/rustc_target/src/spec/targets/powerpc64_unknown_openbsd.rs index 9dc44aa05cc0a..1034a16030269 100644 --- a/compiler/rustc_target/src/spec/targets/powerpc64_unknown_openbsd.rs +++ b/compiler/rustc_target/src/spec/targets/powerpc64_unknown_openbsd.rs @@ -1,7 +1,7 @@ use rustc_abi::Endian; use crate::spec::{ - Cc, LinkerFlavor, Lld, StackProbeType, Target, TargetMetadata, TargetOptions, base, + Arch, Cc, LinkerFlavor, Lld, StackProbeType, Target, TargetMetadata, TargetOptions, base, }; pub(crate) fn target() -> Target { @@ -23,7 +23,7 @@ pub(crate) fn target() -> Target { }, pointer_width: 64, data_layout: "E-m:e-Fn32-i64:64-i128:128-n32:64".into(), - arch: "powerpc64".into(), + arch: Arch::PowerPC64, options: TargetOptions { endian: Endian::Big, mcount: "_mcount".into(), ..base }, } } diff --git a/compiler/rustc_target/src/spec/targets/powerpc64_wrs_vxworks.rs b/compiler/rustc_target/src/spec/targets/powerpc64_wrs_vxworks.rs index 10072f8092deb..fb40316d75dc8 100644 --- a/compiler/rustc_target/src/spec/targets/powerpc64_wrs_vxworks.rs +++ b/compiler/rustc_target/src/spec/targets/powerpc64_wrs_vxworks.rs @@ -1,7 +1,7 @@ use rustc_abi::Endian; use crate::spec::{ - Cc, LinkerFlavor, Lld, StackProbeType, Target, TargetMetadata, TargetOptions, base, + Arch, Cc, LinkerFlavor, Lld, StackProbeType, Target, TargetMetadata, TargetOptions, base, }; pub(crate) fn target() -> Target { @@ -23,7 +23,7 @@ pub(crate) fn target() -> Target { }, pointer_width: 64, data_layout: "E-m:e-Fi64-i64:64-i128:128-n32:64-S128-v256:256:256-v512:512:512".into(), - arch: "powerpc64".into(), + arch: Arch::PowerPC64, options: TargetOptions { endian: Endian::Big, ..base }, } } diff --git a/compiler/rustc_target/src/spec/targets/powerpc64le_unknown_freebsd.rs b/compiler/rustc_target/src/spec/targets/powerpc64le_unknown_freebsd.rs index a7f4e0eabb0a2..7ae74dc882fd2 100644 --- a/compiler/rustc_target/src/spec/targets/powerpc64le_unknown_freebsd.rs +++ b/compiler/rustc_target/src/spec/targets/powerpc64le_unknown_freebsd.rs @@ -1,5 +1,5 @@ use crate::spec::{ - Cc, LinkerFlavor, Lld, StackProbeType, Target, TargetMetadata, TargetOptions, base, + Arch, Cc, LinkerFlavor, Lld, StackProbeType, Target, TargetMetadata, TargetOptions, base, }; pub(crate) fn target() -> Target { @@ -21,7 +21,7 @@ pub(crate) fn target() -> Target { }, pointer_width: 64, data_layout: "e-m:e-Fn32-i64:64-i128:128-n32:64".into(), - arch: "powerpc64".into(), + arch: Arch::PowerPC64, options: TargetOptions { mcount: "_mcount".into(), ..base }, } } diff --git a/compiler/rustc_target/src/spec/targets/powerpc64le_unknown_linux_gnu.rs b/compiler/rustc_target/src/spec/targets/powerpc64le_unknown_linux_gnu.rs index af5704b51ba33..4d1e3dfae4568 100644 --- a/compiler/rustc_target/src/spec/targets/powerpc64le_unknown_linux_gnu.rs +++ b/compiler/rustc_target/src/spec/targets/powerpc64le_unknown_linux_gnu.rs @@ -1,5 +1,5 @@ use crate::spec::{ - Cc, LinkerFlavor, Lld, StackProbeType, Target, TargetMetadata, TargetOptions, base, + Arch, Cc, LinkerFlavor, Lld, StackProbeType, Target, TargetMetadata, TargetOptions, base, }; pub(crate) fn target() -> Target { @@ -21,7 +21,7 @@ pub(crate) fn target() -> Target { }, pointer_width: 64, data_layout: "e-m:e-Fn32-i64:64-i128:128-n32:64-S128-v256:256:256-v512:512:512".into(), - arch: "powerpc64".into(), + arch: Arch::PowerPC64, options: TargetOptions { mcount: "_mcount".into(), ..base }, } } diff --git a/compiler/rustc_target/src/spec/targets/powerpc64le_unknown_linux_musl.rs b/compiler/rustc_target/src/spec/targets/powerpc64le_unknown_linux_musl.rs index 0f8b78fa7307d..3813e29229d9b 100644 --- a/compiler/rustc_target/src/spec/targets/powerpc64le_unknown_linux_musl.rs +++ b/compiler/rustc_target/src/spec/targets/powerpc64le_unknown_linux_musl.rs @@ -1,5 +1,5 @@ use crate::spec::{ - Cc, LinkerFlavor, Lld, StackProbeType, Target, TargetMetadata, TargetOptions, base, + Arch, Cc, LinkerFlavor, Lld, StackProbeType, Target, TargetMetadata, TargetOptions, base, }; pub(crate) fn target() -> Target { @@ -23,7 +23,7 @@ pub(crate) fn target() -> Target { }, pointer_width: 64, data_layout: "e-m:e-Fn32-i64:64-i128:128-n32:64-S128-v256:256:256-v512:512:512".into(), - arch: "powerpc64".into(), + arch: Arch::PowerPC64, options: TargetOptions { mcount: "_mcount".into(), ..base }, } } diff --git a/compiler/rustc_target/src/spec/targets/powerpc_unknown_freebsd.rs b/compiler/rustc_target/src/spec/targets/powerpc_unknown_freebsd.rs index 5e1161e2f7d6c..54f490e0800d1 100644 --- a/compiler/rustc_target/src/spec/targets/powerpc_unknown_freebsd.rs +++ b/compiler/rustc_target/src/spec/targets/powerpc_unknown_freebsd.rs @@ -1,7 +1,7 @@ use rustc_abi::Endian; use crate::spec::{ - Cc, LinkerFlavor, Lld, StackProbeType, Target, TargetMetadata, TargetOptions, base, + Arch, Cc, LinkerFlavor, Lld, StackProbeType, Target, TargetMetadata, TargetOptions, base, }; pub(crate) fn target() -> Target { @@ -24,7 +24,7 @@ pub(crate) fn target() -> Target { }, pointer_width: 32, data_layout: "E-m:e-p:32:32-Fn32-i64:64-n32".into(), - arch: "powerpc".into(), + arch: Arch::PowerPC, options: TargetOptions { endian: Endian::Big, features: "+secure-plt".into(), diff --git a/compiler/rustc_target/src/spec/targets/powerpc_unknown_helenos.rs b/compiler/rustc_target/src/spec/targets/powerpc_unknown_helenos.rs index 2b713e8a5ff2f..9e06faa7d5313 100644 --- a/compiler/rustc_target/src/spec/targets/powerpc_unknown_helenos.rs +++ b/compiler/rustc_target/src/spec/targets/powerpc_unknown_helenos.rs @@ -1,6 +1,6 @@ use rustc_abi::Endian; -use crate::spec::{Target, TargetMetadata, base}; +use crate::spec::{Arch, Target, TargetMetadata, base}; pub(crate) fn target() -> Target { let mut base = base::helenos::opts(); @@ -18,7 +18,7 @@ pub(crate) fn target() -> Target { }, pointer_width: 32, data_layout: "E-m:e-p:32:32-Fn32-i64:64-n32".into(), - arch: "powerpc".into(), + arch: Arch::PowerPC, options: base, } } diff --git a/compiler/rustc_target/src/spec/targets/powerpc_unknown_linux_gnu.rs b/compiler/rustc_target/src/spec/targets/powerpc_unknown_linux_gnu.rs index 6cde4bd98ac10..aa2b694962dce 100644 --- a/compiler/rustc_target/src/spec/targets/powerpc_unknown_linux_gnu.rs +++ b/compiler/rustc_target/src/spec/targets/powerpc_unknown_linux_gnu.rs @@ -1,7 +1,7 @@ use rustc_abi::Endian; use crate::spec::{ - Cc, LinkerFlavor, Lld, StackProbeType, Target, TargetMetadata, TargetOptions, base, + Arch, Cc, LinkerFlavor, Lld, StackProbeType, Target, TargetMetadata, TargetOptions, base, }; pub(crate) fn target() -> Target { @@ -20,7 +20,7 @@ pub(crate) fn target() -> Target { }, pointer_width: 32, data_layout: "E-m:e-p:32:32-Fn32-i64:64-n32".into(), - arch: "powerpc".into(), + arch: Arch::PowerPC, options: TargetOptions { endian: Endian::Big, features: "+secure-plt".into(), diff --git a/compiler/rustc_target/src/spec/targets/powerpc_unknown_linux_gnuspe.rs b/compiler/rustc_target/src/spec/targets/powerpc_unknown_linux_gnuspe.rs index 3c1d18e077719..8bbed94f2f7a0 100644 --- a/compiler/rustc_target/src/spec/targets/powerpc_unknown_linux_gnuspe.rs +++ b/compiler/rustc_target/src/spec/targets/powerpc_unknown_linux_gnuspe.rs @@ -1,7 +1,7 @@ use rustc_abi::Endian; use crate::spec::{ - Cc, LinkerFlavor, Lld, StackProbeType, Target, TargetMetadata, TargetOptions, base, + Arch, Cc, LinkerFlavor, Lld, StackProbeType, Target, TargetMetadata, TargetOptions, base, }; pub(crate) fn target() -> Target { @@ -20,7 +20,7 @@ pub(crate) fn target() -> Target { }, pointer_width: 32, data_layout: "E-m:e-p:32:32-Fn32-i64:64-n32".into(), - arch: "powerpc".into(), + arch: Arch::PowerPC, options: TargetOptions { abi: "spe".into(), endian: Endian::Big, diff --git a/compiler/rustc_target/src/spec/targets/powerpc_unknown_linux_musl.rs b/compiler/rustc_target/src/spec/targets/powerpc_unknown_linux_musl.rs index f5c7cb061988a..7e494e065a048 100644 --- a/compiler/rustc_target/src/spec/targets/powerpc_unknown_linux_musl.rs +++ b/compiler/rustc_target/src/spec/targets/powerpc_unknown_linux_musl.rs @@ -1,7 +1,7 @@ use rustc_abi::Endian; use crate::spec::{ - Cc, LinkerFlavor, Lld, StackProbeType, Target, TargetMetadata, TargetOptions, base, + Arch, Cc, LinkerFlavor, Lld, StackProbeType, Target, TargetMetadata, TargetOptions, base, }; pub(crate) fn target() -> Target { @@ -20,7 +20,7 @@ pub(crate) fn target() -> Target { }, pointer_width: 32, data_layout: "E-m:e-p:32:32-Fn32-i64:64-n32".into(), - arch: "powerpc".into(), + arch: Arch::PowerPC, options: TargetOptions { endian: Endian::Big, mcount: "_mcount".into(), ..base }, } } diff --git a/compiler/rustc_target/src/spec/targets/powerpc_unknown_linux_muslspe.rs b/compiler/rustc_target/src/spec/targets/powerpc_unknown_linux_muslspe.rs index 8ddb45483b3b9..0b6535e5debe0 100644 --- a/compiler/rustc_target/src/spec/targets/powerpc_unknown_linux_muslspe.rs +++ b/compiler/rustc_target/src/spec/targets/powerpc_unknown_linux_muslspe.rs @@ -1,7 +1,7 @@ use rustc_abi::Endian; use crate::spec::{ - Cc, LinkerFlavor, Lld, StackProbeType, Target, TargetMetadata, TargetOptions, base, + Arch, Cc, LinkerFlavor, Lld, StackProbeType, Target, TargetMetadata, TargetOptions, base, }; pub(crate) fn target() -> Target { @@ -20,7 +20,7 @@ pub(crate) fn target() -> Target { }, pointer_width: 32, data_layout: "E-m:e-p:32:32-Fn32-i64:64-n32".into(), - arch: "powerpc".into(), + arch: Arch::PowerPC, options: TargetOptions { abi: "spe".into(), endian: Endian::Big, diff --git a/compiler/rustc_target/src/spec/targets/powerpc_unknown_netbsd.rs b/compiler/rustc_target/src/spec/targets/powerpc_unknown_netbsd.rs index 47a61a1aff244..62e50bbd7ad26 100644 --- a/compiler/rustc_target/src/spec/targets/powerpc_unknown_netbsd.rs +++ b/compiler/rustc_target/src/spec/targets/powerpc_unknown_netbsd.rs @@ -1,7 +1,7 @@ use rustc_abi::Endian; use crate::spec::{ - Cc, LinkerFlavor, Lld, StackProbeType, Target, TargetMetadata, TargetOptions, base, + Arch, Cc, LinkerFlavor, Lld, StackProbeType, Target, TargetMetadata, TargetOptions, base, }; pub(crate) fn target() -> Target { @@ -20,7 +20,7 @@ pub(crate) fn target() -> Target { }, pointer_width: 32, data_layout: "E-m:e-p:32:32-Fn32-i64:64-n32".into(), - arch: "powerpc".into(), + arch: Arch::PowerPC, options: TargetOptions { endian: Endian::Big, mcount: "__mcount".into(), ..base }, } } diff --git a/compiler/rustc_target/src/spec/targets/powerpc_unknown_openbsd.rs b/compiler/rustc_target/src/spec/targets/powerpc_unknown_openbsd.rs index bc5a50a053997..59fccb5910bea 100644 --- a/compiler/rustc_target/src/spec/targets/powerpc_unknown_openbsd.rs +++ b/compiler/rustc_target/src/spec/targets/powerpc_unknown_openbsd.rs @@ -1,6 +1,6 @@ use rustc_abi::Endian; -use crate::spec::{StackProbeType, Target, TargetMetadata, base}; +use crate::spec::{Arch, StackProbeType, Target, TargetMetadata, base}; pub(crate) fn target() -> Target { let mut base = base::openbsd::opts(); @@ -18,7 +18,7 @@ pub(crate) fn target() -> Target { }, pointer_width: 32, data_layout: "E-m:e-p:32:32-Fn32-i64:64-n32".into(), - arch: "powerpc".into(), + arch: Arch::PowerPC, options: base, } } diff --git a/compiler/rustc_target/src/spec/targets/powerpc_wrs_vxworks.rs b/compiler/rustc_target/src/spec/targets/powerpc_wrs_vxworks.rs index ca78be2b2b239..6c587755b8326 100644 --- a/compiler/rustc_target/src/spec/targets/powerpc_wrs_vxworks.rs +++ b/compiler/rustc_target/src/spec/targets/powerpc_wrs_vxworks.rs @@ -1,7 +1,7 @@ use rustc_abi::Endian; use crate::spec::{ - Cc, LinkerFlavor, Lld, StackProbeType, Target, TargetMetadata, TargetOptions, base, + Arch, Cc, LinkerFlavor, Lld, StackProbeType, Target, TargetMetadata, TargetOptions, base, }; pub(crate) fn target() -> Target { @@ -20,7 +20,7 @@ pub(crate) fn target() -> Target { }, pointer_width: 32, data_layout: "E-m:e-p:32:32-Fn32-i64:64-n32".into(), - arch: "powerpc".into(), + arch: Arch::PowerPC, options: TargetOptions { endian: Endian::Big, features: "+secure-plt".into(), ..base }, } } diff --git a/compiler/rustc_target/src/spec/targets/powerpc_wrs_vxworks_spe.rs b/compiler/rustc_target/src/spec/targets/powerpc_wrs_vxworks_spe.rs index e6345629f0397..85de246605d70 100644 --- a/compiler/rustc_target/src/spec/targets/powerpc_wrs_vxworks_spe.rs +++ b/compiler/rustc_target/src/spec/targets/powerpc_wrs_vxworks_spe.rs @@ -1,7 +1,7 @@ use rustc_abi::Endian; use crate::spec::{ - Cc, LinkerFlavor, Lld, StackProbeType, Target, TargetMetadata, TargetOptions, base, + Arch, Cc, LinkerFlavor, Lld, StackProbeType, Target, TargetMetadata, TargetOptions, base, }; pub(crate) fn target() -> Target { @@ -20,7 +20,7 @@ pub(crate) fn target() -> Target { }, pointer_width: 32, data_layout: "E-m:e-p:32:32-Fn32-i64:64-n32".into(), - arch: "powerpc".into(), + arch: Arch::PowerPC, options: TargetOptions { abi: "spe".into(), endian: Endian::Big, diff --git a/compiler/rustc_target/src/spec/targets/riscv32_wrs_vxworks.rs b/compiler/rustc_target/src/spec/targets/riscv32_wrs_vxworks.rs index efc17d8d083b7..3ec8891c95ee3 100644 --- a/compiler/rustc_target/src/spec/targets/riscv32_wrs_vxworks.rs +++ b/compiler/rustc_target/src/spec/targets/riscv32_wrs_vxworks.rs @@ -1,4 +1,4 @@ -use crate::spec::{StackProbeType, Target, TargetMetadata, TargetOptions, base}; +use crate::spec::{Arch, StackProbeType, Target, TargetMetadata, TargetOptions, base}; pub(crate) fn target() -> Target { Target { @@ -11,7 +11,7 @@ pub(crate) fn target() -> Target { }, pointer_width: 32, data_layout: "e-m:e-p:32:32-i64:64-n32-S128".into(), - arch: "riscv32".into(), + arch: Arch::RiscV32, options: TargetOptions { cpu: "generic-rv32".into(), llvm_abiname: "ilp32d".into(), diff --git a/compiler/rustc_target/src/spec/targets/riscv32e_unknown_none_elf.rs b/compiler/rustc_target/src/spec/targets/riscv32e_unknown_none_elf.rs index 00e8532d23846..1f8b2cacd9b53 100644 --- a/compiler/rustc_target/src/spec/targets/riscv32e_unknown_none_elf.rs +++ b/compiler/rustc_target/src/spec/targets/riscv32e_unknown_none_elf.rs @@ -1,5 +1,5 @@ use crate::spec::{ - Cc, LinkerFlavor, Lld, PanicStrategy, RelocModel, Target, TargetMetadata, TargetOptions, + Arch, Cc, LinkerFlavor, Lld, PanicStrategy, RelocModel, Target, TargetMetadata, TargetOptions, }; pub(crate) fn target() -> Target { @@ -16,7 +16,7 @@ pub(crate) fn target() -> Target { std: Some(false), }, pointer_width: 32, - arch: "riscv32".into(), + arch: Arch::RiscV32, options: TargetOptions { abi: abi.into(), diff --git a/compiler/rustc_target/src/spec/targets/riscv32em_unknown_none_elf.rs b/compiler/rustc_target/src/spec/targets/riscv32em_unknown_none_elf.rs index f814201601fc1..1ae868e9b135a 100644 --- a/compiler/rustc_target/src/spec/targets/riscv32em_unknown_none_elf.rs +++ b/compiler/rustc_target/src/spec/targets/riscv32em_unknown_none_elf.rs @@ -1,5 +1,5 @@ use crate::spec::{ - Cc, LinkerFlavor, Lld, PanicStrategy, RelocModel, Target, TargetMetadata, TargetOptions, + Arch, Cc, LinkerFlavor, Lld, PanicStrategy, RelocModel, Target, TargetMetadata, TargetOptions, }; pub(crate) fn target() -> Target { @@ -16,7 +16,7 @@ pub(crate) fn target() -> Target { std: Some(false), }, pointer_width: 32, - arch: "riscv32".into(), + arch: Arch::RiscV32, options: TargetOptions { abi: abi.into(), diff --git a/compiler/rustc_target/src/spec/targets/riscv32emc_unknown_none_elf.rs b/compiler/rustc_target/src/spec/targets/riscv32emc_unknown_none_elf.rs index 33df429db725b..e0958e0f9c5e8 100644 --- a/compiler/rustc_target/src/spec/targets/riscv32emc_unknown_none_elf.rs +++ b/compiler/rustc_target/src/spec/targets/riscv32emc_unknown_none_elf.rs @@ -1,5 +1,5 @@ use crate::spec::{ - Cc, LinkerFlavor, Lld, PanicStrategy, RelocModel, Target, TargetMetadata, TargetOptions, + Arch, Cc, LinkerFlavor, Lld, PanicStrategy, RelocModel, Target, TargetMetadata, TargetOptions, }; pub(crate) fn target() -> Target { @@ -16,7 +16,7 @@ pub(crate) fn target() -> Target { std: Some(false), }, pointer_width: 32, - arch: "riscv32".into(), + arch: Arch::RiscV32, options: TargetOptions { abi: abi.into(), diff --git a/compiler/rustc_target/src/spec/targets/riscv32gc_unknown_linux_gnu.rs b/compiler/rustc_target/src/spec/targets/riscv32gc_unknown_linux_gnu.rs index 5b7feef70d099..29b0f35a205fb 100644 --- a/compiler/rustc_target/src/spec/targets/riscv32gc_unknown_linux_gnu.rs +++ b/compiler/rustc_target/src/spec/targets/riscv32gc_unknown_linux_gnu.rs @@ -1,6 +1,6 @@ use std::borrow::Cow; -use crate::spec::{CodeModel, SplitDebuginfo, Target, TargetMetadata, TargetOptions, base}; +use crate::spec::{Arch, CodeModel, SplitDebuginfo, Target, TargetMetadata, TargetOptions, base}; pub(crate) fn target() -> Target { Target { @@ -13,7 +13,7 @@ pub(crate) fn target() -> Target { }, pointer_width: 32, data_layout: "e-m:e-p:32:32-i64:64-n32-S128".into(), - arch: "riscv32".into(), + arch: Arch::RiscV32, options: TargetOptions { code_model: Some(CodeModel::Medium), cpu: "generic-rv32".into(), diff --git a/compiler/rustc_target/src/spec/targets/riscv32gc_unknown_linux_musl.rs b/compiler/rustc_target/src/spec/targets/riscv32gc_unknown_linux_musl.rs index a13bb173e2483..28116052151e7 100644 --- a/compiler/rustc_target/src/spec/targets/riscv32gc_unknown_linux_musl.rs +++ b/compiler/rustc_target/src/spec/targets/riscv32gc_unknown_linux_musl.rs @@ -1,6 +1,6 @@ use std::borrow::Cow; -use crate::spec::{CodeModel, SplitDebuginfo, Target, TargetMetadata, TargetOptions, base}; +use crate::spec::{Arch, CodeModel, SplitDebuginfo, Target, TargetMetadata, TargetOptions, base}; pub(crate) fn target() -> Target { Target { @@ -13,7 +13,7 @@ pub(crate) fn target() -> Target { }, pointer_width: 32, data_layout: "e-m:e-p:32:32-i64:64-n32-S128".into(), - arch: "riscv32".into(), + arch: Arch::RiscV32, options: TargetOptions { code_model: Some(CodeModel::Medium), cpu: "generic-rv32".into(), diff --git a/compiler/rustc_target/src/spec/targets/riscv32i_unknown_none_elf.rs b/compiler/rustc_target/src/spec/targets/riscv32i_unknown_none_elf.rs index f9a3b2172205b..bd6375fef1631 100644 --- a/compiler/rustc_target/src/spec/targets/riscv32i_unknown_none_elf.rs +++ b/compiler/rustc_target/src/spec/targets/riscv32i_unknown_none_elf.rs @@ -1,5 +1,5 @@ use crate::spec::{ - Cc, LinkerFlavor, Lld, PanicStrategy, RelocModel, Target, TargetMetadata, TargetOptions, + Arch, Cc, LinkerFlavor, Lld, PanicStrategy, RelocModel, Target, TargetMetadata, TargetOptions, }; pub(crate) fn target() -> Target { @@ -13,7 +13,7 @@ pub(crate) fn target() -> Target { std: Some(false), }, pointer_width: 32, - arch: "riscv32".into(), + arch: Arch::RiscV32, options: TargetOptions { linker_flavor: LinkerFlavor::Gnu(Cc::No, Lld::Yes), diff --git a/compiler/rustc_target/src/spec/targets/riscv32im_risc0_zkvm_elf.rs b/compiler/rustc_target/src/spec/targets/riscv32im_risc0_zkvm_elf.rs index 162f21c42ba27..c0372035cd7e6 100644 --- a/compiler/rustc_target/src/spec/targets/riscv32im_risc0_zkvm_elf.rs +++ b/compiler/rustc_target/src/spec/targets/riscv32im_risc0_zkvm_elf.rs @@ -1,5 +1,5 @@ use crate::spec::{ - Cc, LinkerFlavor, Lld, PanicStrategy, RelocModel, Target, TargetMetadata, TargetOptions, + Arch, Cc, LinkerFlavor, Lld, PanicStrategy, RelocModel, Target, TargetMetadata, TargetOptions, }; pub(crate) fn target() -> Target { @@ -13,7 +13,7 @@ pub(crate) fn target() -> Target { std: None, // ? }, pointer_width: 32, - arch: "riscv32".into(), + arch: Arch::RiscV32, options: TargetOptions { os: "zkvm".into(), diff --git a/compiler/rustc_target/src/spec/targets/riscv32im_unknown_none_elf.rs b/compiler/rustc_target/src/spec/targets/riscv32im_unknown_none_elf.rs index 47b408a12d171..5aef58b153d15 100644 --- a/compiler/rustc_target/src/spec/targets/riscv32im_unknown_none_elf.rs +++ b/compiler/rustc_target/src/spec/targets/riscv32im_unknown_none_elf.rs @@ -1,5 +1,5 @@ use crate::spec::{ - Cc, LinkerFlavor, Lld, PanicStrategy, RelocModel, Target, TargetMetadata, TargetOptions, + Arch, Cc, LinkerFlavor, Lld, PanicStrategy, RelocModel, Target, TargetMetadata, TargetOptions, }; pub(crate) fn target() -> Target { @@ -13,7 +13,7 @@ pub(crate) fn target() -> Target { std: Some(false), }, pointer_width: 32, - arch: "riscv32".into(), + arch: Arch::RiscV32, options: TargetOptions { linker_flavor: LinkerFlavor::Gnu(Cc::No, Lld::Yes), diff --git a/compiler/rustc_target/src/spec/targets/riscv32ima_unknown_none_elf.rs b/compiler/rustc_target/src/spec/targets/riscv32ima_unknown_none_elf.rs index a173fb00b329e..c455f654b4006 100644 --- a/compiler/rustc_target/src/spec/targets/riscv32ima_unknown_none_elf.rs +++ b/compiler/rustc_target/src/spec/targets/riscv32ima_unknown_none_elf.rs @@ -1,5 +1,5 @@ use crate::spec::{ - Cc, LinkerFlavor, Lld, PanicStrategy, RelocModel, Target, TargetMetadata, TargetOptions, + Arch, Cc, LinkerFlavor, Lld, PanicStrategy, RelocModel, Target, TargetMetadata, TargetOptions, }; pub(crate) fn target() -> Target { @@ -13,7 +13,7 @@ pub(crate) fn target() -> Target { std: Some(false), }, pointer_width: 32, - arch: "riscv32".into(), + arch: Arch::RiscV32, options: TargetOptions { linker_flavor: LinkerFlavor::Gnu(Cc::No, Lld::Yes), diff --git a/compiler/rustc_target/src/spec/targets/riscv32imac_esp_espidf.rs b/compiler/rustc_target/src/spec/targets/riscv32imac_esp_espidf.rs index 48db9f44eacd3..6b3e5a47ad874 100644 --- a/compiler/rustc_target/src/spec/targets/riscv32imac_esp_espidf.rs +++ b/compiler/rustc_target/src/spec/targets/riscv32imac_esp_espidf.rs @@ -1,4 +1,4 @@ -use crate::spec::{PanicStrategy, RelocModel, Target, TargetMetadata, TargetOptions, cvs}; +use crate::spec::{Arch, PanicStrategy, RelocModel, Target, TargetMetadata, TargetOptions, cvs}; pub(crate) fn target() -> Target { Target { @@ -11,7 +11,7 @@ pub(crate) fn target() -> Target { std: Some(true), }, pointer_width: 32, - arch: "riscv32".into(), + arch: Arch::RiscV32, options: TargetOptions { families: cvs!["unix"], diff --git a/compiler/rustc_target/src/spec/targets/riscv32imac_unknown_none_elf.rs b/compiler/rustc_target/src/spec/targets/riscv32imac_unknown_none_elf.rs index 1608f051ea821..deca348b9e1b9 100644 --- a/compiler/rustc_target/src/spec/targets/riscv32imac_unknown_none_elf.rs +++ b/compiler/rustc_target/src/spec/targets/riscv32imac_unknown_none_elf.rs @@ -1,5 +1,5 @@ use crate::spec::{ - Cc, LinkerFlavor, Lld, PanicStrategy, RelocModel, Target, TargetMetadata, TargetOptions, + Arch, Cc, LinkerFlavor, Lld, PanicStrategy, RelocModel, Target, TargetMetadata, TargetOptions, }; pub(crate) fn target() -> Target { @@ -13,7 +13,7 @@ pub(crate) fn target() -> Target { std: Some(false), }, pointer_width: 32, - arch: "riscv32".into(), + arch: Arch::RiscV32, options: TargetOptions { linker_flavor: LinkerFlavor::Gnu(Cc::No, Lld::Yes), diff --git a/compiler/rustc_target/src/spec/targets/riscv32imac_unknown_nuttx_elf.rs b/compiler/rustc_target/src/spec/targets/riscv32imac_unknown_nuttx_elf.rs index 4ee02c6b2956f..70eb7cb78d659 100644 --- a/compiler/rustc_target/src/spec/targets/riscv32imac_unknown_nuttx_elf.rs +++ b/compiler/rustc_target/src/spec/targets/riscv32imac_unknown_nuttx_elf.rs @@ -1,5 +1,6 @@ use crate::spec::{ - Cc, LinkerFlavor, Lld, PanicStrategy, RelocModel, Target, TargetMetadata, TargetOptions, cvs, + Arch, Cc, LinkerFlavor, Lld, PanicStrategy, RelocModel, Target, TargetMetadata, TargetOptions, + cvs, }; pub(crate) fn target() -> Target { @@ -13,7 +14,7 @@ pub(crate) fn target() -> Target { std: Some(true), }, pointer_width: 32, - arch: "riscv32".into(), + arch: Arch::RiscV32, options: TargetOptions { families: cvs!["unix"], diff --git a/compiler/rustc_target/src/spec/targets/riscv32imac_unknown_xous_elf.rs b/compiler/rustc_target/src/spec/targets/riscv32imac_unknown_xous_elf.rs index 0893bd5ad6dca..e50de1cc93714 100644 --- a/compiler/rustc_target/src/spec/targets/riscv32imac_unknown_xous_elf.rs +++ b/compiler/rustc_target/src/spec/targets/riscv32imac_unknown_xous_elf.rs @@ -1,5 +1,5 @@ use crate::spec::{ - Cc, LinkerFlavor, Lld, PanicStrategy, RelocModel, Target, TargetMetadata, TargetOptions, + Arch, Cc, LinkerFlavor, Lld, PanicStrategy, RelocModel, Target, TargetMetadata, TargetOptions, }; pub(crate) fn target() -> Target { @@ -13,7 +13,7 @@ pub(crate) fn target() -> Target { std: None, // ? }, pointer_width: 32, - arch: "riscv32".into(), + arch: Arch::RiscV32, options: TargetOptions { os: "xous".into(), diff --git a/compiler/rustc_target/src/spec/targets/riscv32imafc_esp_espidf.rs b/compiler/rustc_target/src/spec/targets/riscv32imafc_esp_espidf.rs index 0929af7bb75ff..196a3de95cfb5 100644 --- a/compiler/rustc_target/src/spec/targets/riscv32imafc_esp_espidf.rs +++ b/compiler/rustc_target/src/spec/targets/riscv32imafc_esp_espidf.rs @@ -1,4 +1,4 @@ -use crate::spec::{PanicStrategy, RelocModel, Target, TargetMetadata, TargetOptions, cvs}; +use crate::spec::{Arch, PanicStrategy, RelocModel, Target, TargetMetadata, TargetOptions, cvs}; pub(crate) fn target() -> Target { Target { @@ -11,7 +11,7 @@ pub(crate) fn target() -> Target { std: Some(true), }, pointer_width: 32, - arch: "riscv32".into(), + arch: Arch::RiscV32, options: TargetOptions { families: cvs!["unix"], diff --git a/compiler/rustc_target/src/spec/targets/riscv32imafc_unknown_none_elf.rs b/compiler/rustc_target/src/spec/targets/riscv32imafc_unknown_none_elf.rs index 44a84d9082cdf..21f683516f7cd 100644 --- a/compiler/rustc_target/src/spec/targets/riscv32imafc_unknown_none_elf.rs +++ b/compiler/rustc_target/src/spec/targets/riscv32imafc_unknown_none_elf.rs @@ -1,5 +1,5 @@ use crate::spec::{ - Cc, LinkerFlavor, Lld, PanicStrategy, RelocModel, Target, TargetMetadata, TargetOptions, + Arch, Cc, LinkerFlavor, Lld, PanicStrategy, RelocModel, Target, TargetMetadata, TargetOptions, }; pub(crate) fn target() -> Target { @@ -13,7 +13,7 @@ pub(crate) fn target() -> Target { std: Some(false), }, pointer_width: 32, - arch: "riscv32".into(), + arch: Arch::RiscV32, options: TargetOptions { linker_flavor: LinkerFlavor::Gnu(Cc::No, Lld::Yes), diff --git a/compiler/rustc_target/src/spec/targets/riscv32imafc_unknown_nuttx_elf.rs b/compiler/rustc_target/src/spec/targets/riscv32imafc_unknown_nuttx_elf.rs index 8908c0c53d9fe..f7b8bd49e5276 100644 --- a/compiler/rustc_target/src/spec/targets/riscv32imafc_unknown_nuttx_elf.rs +++ b/compiler/rustc_target/src/spec/targets/riscv32imafc_unknown_nuttx_elf.rs @@ -1,5 +1,6 @@ use crate::spec::{ - Cc, LinkerFlavor, Lld, PanicStrategy, RelocModel, Target, TargetMetadata, TargetOptions, cvs, + Arch, Cc, LinkerFlavor, Lld, PanicStrategy, RelocModel, Target, TargetMetadata, TargetOptions, + cvs, }; pub(crate) fn target() -> Target { @@ -13,7 +14,7 @@ pub(crate) fn target() -> Target { std: Some(true), }, pointer_width: 32, - arch: "riscv32".into(), + arch: Arch::RiscV32, options: TargetOptions { families: cvs!["unix"], diff --git a/compiler/rustc_target/src/spec/targets/riscv32imc_esp_espidf.rs b/compiler/rustc_target/src/spec/targets/riscv32imc_esp_espidf.rs index 82a4d58a3986f..66c64667d0dca 100644 --- a/compiler/rustc_target/src/spec/targets/riscv32imc_esp_espidf.rs +++ b/compiler/rustc_target/src/spec/targets/riscv32imc_esp_espidf.rs @@ -1,4 +1,4 @@ -use crate::spec::{PanicStrategy, RelocModel, Target, TargetMetadata, TargetOptions, cvs}; +use crate::spec::{Arch, PanicStrategy, RelocModel, Target, TargetMetadata, TargetOptions, cvs}; pub(crate) fn target() -> Target { Target { @@ -11,7 +11,7 @@ pub(crate) fn target() -> Target { std: Some(true), }, pointer_width: 32, - arch: "riscv32".into(), + arch: Arch::RiscV32, options: TargetOptions { families: cvs!["unix"], diff --git a/compiler/rustc_target/src/spec/targets/riscv32imc_unknown_none_elf.rs b/compiler/rustc_target/src/spec/targets/riscv32imc_unknown_none_elf.rs index 755ffc6154a18..0b8e447442064 100644 --- a/compiler/rustc_target/src/spec/targets/riscv32imc_unknown_none_elf.rs +++ b/compiler/rustc_target/src/spec/targets/riscv32imc_unknown_none_elf.rs @@ -1,5 +1,5 @@ use crate::spec::{ - Cc, LinkerFlavor, Lld, PanicStrategy, RelocModel, Target, TargetMetadata, TargetOptions, + Arch, Cc, LinkerFlavor, Lld, PanicStrategy, RelocModel, Target, TargetMetadata, TargetOptions, }; pub(crate) fn target() -> Target { @@ -13,7 +13,7 @@ pub(crate) fn target() -> Target { std: Some(false), }, pointer_width: 32, - arch: "riscv32".into(), + arch: Arch::RiscV32, options: TargetOptions { linker_flavor: LinkerFlavor::Gnu(Cc::No, Lld::Yes), diff --git a/compiler/rustc_target/src/spec/targets/riscv32imc_unknown_nuttx_elf.rs b/compiler/rustc_target/src/spec/targets/riscv32imc_unknown_nuttx_elf.rs index 8da0b0e3e6b27..a10ddb2d05697 100644 --- a/compiler/rustc_target/src/spec/targets/riscv32imc_unknown_nuttx_elf.rs +++ b/compiler/rustc_target/src/spec/targets/riscv32imc_unknown_nuttx_elf.rs @@ -1,5 +1,6 @@ use crate::spec::{ - Cc, LinkerFlavor, Lld, PanicStrategy, RelocModel, Target, TargetMetadata, TargetOptions, cvs, + Arch, Cc, LinkerFlavor, Lld, PanicStrategy, RelocModel, Target, TargetMetadata, TargetOptions, + cvs, }; pub(crate) fn target() -> Target { @@ -13,7 +14,7 @@ pub(crate) fn target() -> Target { std: Some(true), }, pointer_width: 32, - arch: "riscv32".into(), + arch: Arch::RiscV32, options: TargetOptions { families: cvs!["unix"], diff --git a/compiler/rustc_target/src/spec/targets/riscv64_linux_android.rs b/compiler/rustc_target/src/spec/targets/riscv64_linux_android.rs index b9176c939f805..404f4143c5be6 100644 --- a/compiler/rustc_target/src/spec/targets/riscv64_linux_android.rs +++ b/compiler/rustc_target/src/spec/targets/riscv64_linux_android.rs @@ -1,7 +1,7 @@ use std::borrow::Cow; use crate::spec::{ - CodeModel, SanitizerSet, SplitDebuginfo, Target, TargetMetadata, TargetOptions, base, + Arch, CodeModel, SanitizerSet, SplitDebuginfo, Target, TargetMetadata, TargetOptions, base, }; pub(crate) fn target() -> Target { @@ -15,7 +15,7 @@ pub(crate) fn target() -> Target { }, pointer_width: 64, data_layout: "e-m:e-p:64:64-i64:64-i128:128-n32:64-S128".into(), - arch: "riscv64".into(), + arch: Arch::RiscV64, options: TargetOptions { code_model: Some(CodeModel::Medium), cpu: "generic-rv64".into(), diff --git a/compiler/rustc_target/src/spec/targets/riscv64_wrs_vxworks.rs b/compiler/rustc_target/src/spec/targets/riscv64_wrs_vxworks.rs index 8d8c21952de5f..c6fffc2515294 100644 --- a/compiler/rustc_target/src/spec/targets/riscv64_wrs_vxworks.rs +++ b/compiler/rustc_target/src/spec/targets/riscv64_wrs_vxworks.rs @@ -1,4 +1,4 @@ -use crate::spec::{StackProbeType, Target, TargetMetadata, TargetOptions, base}; +use crate::spec::{Arch, StackProbeType, Target, TargetMetadata, TargetOptions, base}; pub(crate) fn target() -> Target { Target { @@ -11,7 +11,7 @@ pub(crate) fn target() -> Target { }, pointer_width: 64, data_layout: "e-m:e-p:64:64-i64:64-i128:128-n32:64-S128".into(), - arch: "riscv64".into(), + arch: Arch::RiscV64, options: TargetOptions { cpu: "generic-rv64".into(), llvm_abiname: "lp64d".into(), diff --git a/compiler/rustc_target/src/spec/targets/riscv64a23_unknown_linux_gnu.rs b/compiler/rustc_target/src/spec/targets/riscv64a23_unknown_linux_gnu.rs index 60f2e7da042cc..39db793af0de3 100644 --- a/compiler/rustc_target/src/spec/targets/riscv64a23_unknown_linux_gnu.rs +++ b/compiler/rustc_target/src/spec/targets/riscv64a23_unknown_linux_gnu.rs @@ -1,6 +1,6 @@ use std::borrow::Cow; -use crate::spec::{CodeModel, SplitDebuginfo, Target, TargetMetadata, TargetOptions, base}; +use crate::spec::{Arch, CodeModel, SplitDebuginfo, Target, TargetMetadata, TargetOptions, base}; pub(crate) fn target() -> Target { Target { @@ -13,7 +13,7 @@ pub(crate) fn target() -> Target { }, pointer_width: 64, data_layout: "e-m:e-p:64:64-i64:64-i128:128-n32:64-S128".into(), - arch: "riscv64".into(), + arch: Arch::RiscV64, options: TargetOptions { code_model: Some(CodeModel::Medium), cpu: "generic-rv64".into(), diff --git a/compiler/rustc_target/src/spec/targets/riscv64gc_unknown_freebsd.rs b/compiler/rustc_target/src/spec/targets/riscv64gc_unknown_freebsd.rs index e628095b88a6d..dbcfbc38ece68 100644 --- a/compiler/rustc_target/src/spec/targets/riscv64gc_unknown_freebsd.rs +++ b/compiler/rustc_target/src/spec/targets/riscv64gc_unknown_freebsd.rs @@ -1,4 +1,4 @@ -use crate::spec::{CodeModel, Target, TargetMetadata, TargetOptions, base}; +use crate::spec::{Arch, CodeModel, Target, TargetMetadata, TargetOptions, base}; pub(crate) fn target() -> Target { Target { @@ -11,7 +11,7 @@ pub(crate) fn target() -> Target { }, pointer_width: 64, data_layout: "e-m:e-p:64:64-i64:64-i128:128-n32:64-S128".into(), - arch: "riscv64".into(), + arch: Arch::RiscV64, options: TargetOptions { code_model: Some(CodeModel::Medium), cpu: "generic-rv64".into(), diff --git a/compiler/rustc_target/src/spec/targets/riscv64gc_unknown_fuchsia.rs b/compiler/rustc_target/src/spec/targets/riscv64gc_unknown_fuchsia.rs index c4466e13d1439..c3a45254b712c 100644 --- a/compiler/rustc_target/src/spec/targets/riscv64gc_unknown_fuchsia.rs +++ b/compiler/rustc_target/src/spec/targets/riscv64gc_unknown_fuchsia.rs @@ -1,4 +1,4 @@ -use crate::spec::{CodeModel, SanitizerSet, StackProbeType, Target, TargetMetadata, base}; +use crate::spec::{Arch, CodeModel, SanitizerSet, StackProbeType, Target, TargetMetadata, base}; pub(crate) fn target() -> Target { let mut base = base::fuchsia::opts(); @@ -21,7 +21,7 @@ pub(crate) fn target() -> Target { }, pointer_width: 64, data_layout: "e-m:e-p:64:64-i64:64-i128:128-n32:64-S128".into(), - arch: "riscv64".into(), + arch: Arch::RiscV64, options: base, } } diff --git a/compiler/rustc_target/src/spec/targets/riscv64gc_unknown_hermit.rs b/compiler/rustc_target/src/spec/targets/riscv64gc_unknown_hermit.rs index 5c15bdd9f6454..68f69044bb254 100644 --- a/compiler/rustc_target/src/spec/targets/riscv64gc_unknown_hermit.rs +++ b/compiler/rustc_target/src/spec/targets/riscv64gc_unknown_hermit.rs @@ -1,4 +1,6 @@ -use crate::spec::{CodeModel, RelocModel, Target, TargetMetadata, TargetOptions, TlsModel, base}; +use crate::spec::{ + Arch, CodeModel, RelocModel, Target, TargetMetadata, TargetOptions, TlsModel, base, +}; pub(crate) fn target() -> Target { Target { @@ -10,7 +12,7 @@ pub(crate) fn target() -> Target { std: Some(true), }, pointer_width: 64, - arch: "riscv64".into(), + arch: Arch::RiscV64, data_layout: "e-m:e-p:64:64-i64:64-i128:128-n32:64-S128".into(), options: TargetOptions { cpu: "generic-rv64".into(), diff --git a/compiler/rustc_target/src/spec/targets/riscv64gc_unknown_linux_gnu.rs b/compiler/rustc_target/src/spec/targets/riscv64gc_unknown_linux_gnu.rs index af2f42fa00a2f..333a63a251588 100644 --- a/compiler/rustc_target/src/spec/targets/riscv64gc_unknown_linux_gnu.rs +++ b/compiler/rustc_target/src/spec/targets/riscv64gc_unknown_linux_gnu.rs @@ -1,6 +1,6 @@ use std::borrow::Cow; -use crate::spec::{CodeModel, SplitDebuginfo, Target, TargetMetadata, TargetOptions, base}; +use crate::spec::{Arch, CodeModel, SplitDebuginfo, Target, TargetMetadata, TargetOptions, base}; pub(crate) fn target() -> Target { Target { @@ -13,7 +13,7 @@ pub(crate) fn target() -> Target { }, pointer_width: 64, data_layout: "e-m:e-p:64:64-i64:64-i128:128-n32:64-S128".into(), - arch: "riscv64".into(), + arch: Arch::RiscV64, options: TargetOptions { code_model: Some(CodeModel::Medium), cpu: "generic-rv64".into(), diff --git a/compiler/rustc_target/src/spec/targets/riscv64gc_unknown_linux_musl.rs b/compiler/rustc_target/src/spec/targets/riscv64gc_unknown_linux_musl.rs index 83fd4e2cfa9ee..f5d647d0fc545 100644 --- a/compiler/rustc_target/src/spec/targets/riscv64gc_unknown_linux_musl.rs +++ b/compiler/rustc_target/src/spec/targets/riscv64gc_unknown_linux_musl.rs @@ -1,6 +1,6 @@ use std::borrow::Cow; -use crate::spec::{CodeModel, SplitDebuginfo, Target, TargetMetadata, TargetOptions, base}; +use crate::spec::{Arch, CodeModel, SplitDebuginfo, Target, TargetMetadata, TargetOptions, base}; pub(crate) fn target() -> Target { Target { @@ -13,7 +13,7 @@ pub(crate) fn target() -> Target { }, pointer_width: 64, data_layout: "e-m:e-p:64:64-i64:64-i128:128-n32:64-S128".into(), - arch: "riscv64".into(), + arch: Arch::RiscV64, options: TargetOptions { code_model: Some(CodeModel::Medium), cpu: "generic-rv64".into(), diff --git a/compiler/rustc_target/src/spec/targets/riscv64gc_unknown_managarm_mlibc.rs b/compiler/rustc_target/src/spec/targets/riscv64gc_unknown_managarm_mlibc.rs index abf28310634ae..a9ecf27e91345 100644 --- a/compiler/rustc_target/src/spec/targets/riscv64gc_unknown_managarm_mlibc.rs +++ b/compiler/rustc_target/src/spec/targets/riscv64gc_unknown_managarm_mlibc.rs @@ -1,4 +1,4 @@ -use crate::spec::{CodeModel, Target, TargetOptions, base}; +use crate::spec::{Arch, CodeModel, Target, TargetOptions, base}; pub(crate) fn target() -> Target { Target { @@ -11,7 +11,7 @@ pub(crate) fn target() -> Target { }, pointer_width: 64, data_layout: "e-m:e-p:64:64-i64:64-i128:128-n32:64-S128".into(), - arch: "riscv64".into(), + arch: Arch::RiscV64, options: TargetOptions { code_model: Some(CodeModel::Medium), cpu: "generic-rv64".into(), diff --git a/compiler/rustc_target/src/spec/targets/riscv64gc_unknown_netbsd.rs b/compiler/rustc_target/src/spec/targets/riscv64gc_unknown_netbsd.rs index 1f359d1e7fe6d..bc929a07f9c04 100644 --- a/compiler/rustc_target/src/spec/targets/riscv64gc_unknown_netbsd.rs +++ b/compiler/rustc_target/src/spec/targets/riscv64gc_unknown_netbsd.rs @@ -1,4 +1,4 @@ -use crate::spec::{CodeModel, Target, TargetMetadata, TargetOptions, base}; +use crate::spec::{Arch, CodeModel, Target, TargetMetadata, TargetOptions, base}; pub(crate) fn target() -> Target { Target { @@ -11,7 +11,7 @@ pub(crate) fn target() -> Target { }, pointer_width: 64, data_layout: "e-m:e-p:64:64-i64:64-i128:128-n32:64-S128".into(), - arch: "riscv64".into(), + arch: Arch::RiscV64, options: TargetOptions { code_model: Some(CodeModel::Medium), cpu: "generic-rv64".into(), diff --git a/compiler/rustc_target/src/spec/targets/riscv64gc_unknown_none_elf.rs b/compiler/rustc_target/src/spec/targets/riscv64gc_unknown_none_elf.rs index 5a5aad93efba1..b06727efc9ee6 100644 --- a/compiler/rustc_target/src/spec/targets/riscv64gc_unknown_none_elf.rs +++ b/compiler/rustc_target/src/spec/targets/riscv64gc_unknown_none_elf.rs @@ -1,5 +1,5 @@ use crate::spec::{ - Cc, CodeModel, LinkerFlavor, Lld, PanicStrategy, RelocModel, SanitizerSet, Target, + Arch, Cc, CodeModel, LinkerFlavor, Lld, PanicStrategy, RelocModel, SanitizerSet, Target, TargetMetadata, TargetOptions, }; @@ -14,7 +14,7 @@ pub(crate) fn target() -> Target { }, llvm_target: "riscv64".into(), pointer_width: 64, - arch: "riscv64".into(), + arch: Arch::RiscV64, options: TargetOptions { linker_flavor: LinkerFlavor::Gnu(Cc::No, Lld::Yes), diff --git a/compiler/rustc_target/src/spec/targets/riscv64gc_unknown_nuttx_elf.rs b/compiler/rustc_target/src/spec/targets/riscv64gc_unknown_nuttx_elf.rs index e8abc926dd0ed..93dd6dc7ed1c1 100644 --- a/compiler/rustc_target/src/spec/targets/riscv64gc_unknown_nuttx_elf.rs +++ b/compiler/rustc_target/src/spec/targets/riscv64gc_unknown_nuttx_elf.rs @@ -1,5 +1,5 @@ use crate::spec::{ - Cc, CodeModel, LinkerFlavor, Lld, PanicStrategy, RelocModel, SanitizerSet, Target, + Arch, Cc, CodeModel, LinkerFlavor, Lld, PanicStrategy, RelocModel, SanitizerSet, Target, TargetMetadata, TargetOptions, cvs, }; @@ -14,7 +14,7 @@ pub(crate) fn target() -> Target { }, llvm_target: "riscv64".into(), pointer_width: 64, - arch: "riscv64".into(), + arch: Arch::RiscV64, options: TargetOptions { families: cvs!["unix"], diff --git a/compiler/rustc_target/src/spec/targets/riscv64gc_unknown_openbsd.rs b/compiler/rustc_target/src/spec/targets/riscv64gc_unknown_openbsd.rs index 85d7dfe7865ed..fb7b077c963d4 100644 --- a/compiler/rustc_target/src/spec/targets/riscv64gc_unknown_openbsd.rs +++ b/compiler/rustc_target/src/spec/targets/riscv64gc_unknown_openbsd.rs @@ -1,4 +1,4 @@ -use crate::spec::{CodeModel, Target, TargetMetadata, TargetOptions, base}; +use crate::spec::{Arch, CodeModel, Target, TargetMetadata, TargetOptions, base}; pub(crate) fn target() -> Target { Target { @@ -11,7 +11,7 @@ pub(crate) fn target() -> Target { }, pointer_width: 64, data_layout: "e-m:e-p:64:64-i64:64-i128:128-n32:64-S128".into(), - arch: "riscv64".into(), + arch: Arch::RiscV64, options: TargetOptions { code_model: Some(CodeModel::Medium), cpu: "generic-rv64".into(), diff --git a/compiler/rustc_target/src/spec/targets/riscv64gc_unknown_redox.rs b/compiler/rustc_target/src/spec/targets/riscv64gc_unknown_redox.rs index 01276a8be465e..b6e88646d4e24 100644 --- a/compiler/rustc_target/src/spec/targets/riscv64gc_unknown_redox.rs +++ b/compiler/rustc_target/src/spec/targets/riscv64gc_unknown_redox.rs @@ -1,4 +1,4 @@ -use crate::spec::{CodeModel, Target, TargetMetadata, base}; +use crate::spec::{Arch, CodeModel, Target, TargetMetadata, base}; pub(crate) fn target() -> Target { let mut base = base::redox::opts(); @@ -19,7 +19,7 @@ pub(crate) fn target() -> Target { }, pointer_width: 64, data_layout: "e-m:e-p:64:64-i64:64-i128:128-n32:64-S128".into(), - arch: "riscv64".into(), + arch: Arch::RiscV64, options: base, } } diff --git a/compiler/rustc_target/src/spec/targets/riscv64imac_unknown_none_elf.rs b/compiler/rustc_target/src/spec/targets/riscv64imac_unknown_none_elf.rs index 5c5d4aa32a2c4..60ee41b47dfd3 100644 --- a/compiler/rustc_target/src/spec/targets/riscv64imac_unknown_none_elf.rs +++ b/compiler/rustc_target/src/spec/targets/riscv64imac_unknown_none_elf.rs @@ -1,5 +1,5 @@ use crate::spec::{ - Cc, CodeModel, LinkerFlavor, Lld, PanicStrategy, RelocModel, SanitizerSet, Target, + Arch, Cc, CodeModel, LinkerFlavor, Lld, PanicStrategy, RelocModel, SanitizerSet, Target, TargetMetadata, TargetOptions, }; @@ -14,7 +14,7 @@ pub(crate) fn target() -> Target { std: Some(false), }, pointer_width: 64, - arch: "riscv64".into(), + arch: Arch::RiscV64, options: TargetOptions { linker_flavor: LinkerFlavor::Gnu(Cc::No, Lld::Yes), diff --git a/compiler/rustc_target/src/spec/targets/riscv64imac_unknown_nuttx_elf.rs b/compiler/rustc_target/src/spec/targets/riscv64imac_unknown_nuttx_elf.rs index 0928250dba64d..25e3e72f9de97 100644 --- a/compiler/rustc_target/src/spec/targets/riscv64imac_unknown_nuttx_elf.rs +++ b/compiler/rustc_target/src/spec/targets/riscv64imac_unknown_nuttx_elf.rs @@ -1,5 +1,5 @@ use crate::spec::{ - Cc, CodeModel, LinkerFlavor, Lld, PanicStrategy, RelocModel, SanitizerSet, Target, + Arch, Cc, CodeModel, LinkerFlavor, Lld, PanicStrategy, RelocModel, SanitizerSet, Target, TargetMetadata, TargetOptions, cvs, }; @@ -14,7 +14,7 @@ pub(crate) fn target() -> Target { }, llvm_target: "riscv64".into(), pointer_width: 64, - arch: "riscv64".into(), + arch: Arch::RiscV64, options: TargetOptions { families: cvs!["unix"], diff --git a/compiler/rustc_target/src/spec/targets/s390x_unknown_linux_gnu.rs b/compiler/rustc_target/src/spec/targets/s390x_unknown_linux_gnu.rs index cdcf7d62a3e2b..a64e867b9a1cb 100644 --- a/compiler/rustc_target/src/spec/targets/s390x_unknown_linux_gnu.rs +++ b/compiler/rustc_target/src/spec/targets/s390x_unknown_linux_gnu.rs @@ -1,6 +1,6 @@ use rustc_abi::{Align, Endian}; -use crate::spec::{SanitizerSet, StackProbeType, Target, TargetMetadata, base}; +use crate::spec::{Arch, SanitizerSet, StackProbeType, Target, TargetMetadata, base}; pub(crate) fn target() -> Target { let mut base = base::linux_gnu::opts(); @@ -23,7 +23,7 @@ pub(crate) fn target() -> Target { }, pointer_width: 64, data_layout: "E-m:e-i1:8:16-i8:8:16-i64:64-f128:64-v128:64-a:8:16-n32:64".into(), - arch: "s390x".into(), + arch: Arch::S390x, options: base, } } diff --git a/compiler/rustc_target/src/spec/targets/s390x_unknown_linux_musl.rs b/compiler/rustc_target/src/spec/targets/s390x_unknown_linux_musl.rs index 509105afedcd2..69c25d72432c5 100644 --- a/compiler/rustc_target/src/spec/targets/s390x_unknown_linux_musl.rs +++ b/compiler/rustc_target/src/spec/targets/s390x_unknown_linux_musl.rs @@ -1,6 +1,6 @@ use rustc_abi::{Align, Endian}; -use crate::spec::{SanitizerSet, StackProbeType, Target, TargetMetadata, base}; +use crate::spec::{Arch, SanitizerSet, StackProbeType, Target, TargetMetadata, base}; pub(crate) fn target() -> Target { let mut base = base::linux_musl::opts(); @@ -24,7 +24,7 @@ pub(crate) fn target() -> Target { }, pointer_width: 64, data_layout: "E-m:e-i1:8:16-i8:8:16-i64:64-f128:64-v128:64-a:8:16-n32:64".into(), - arch: "s390x".into(), + arch: Arch::S390x, options: base, } } diff --git a/compiler/rustc_target/src/spec/targets/sparc64_unknown_helenos.rs b/compiler/rustc_target/src/spec/targets/sparc64_unknown_helenos.rs index 8c3def57d0cf4..c5d5657bf8162 100644 --- a/compiler/rustc_target/src/spec/targets/sparc64_unknown_helenos.rs +++ b/compiler/rustc_target/src/spec/targets/sparc64_unknown_helenos.rs @@ -1,6 +1,6 @@ use rustc_abi::Endian; -use crate::spec::{Cc, LinkerFlavor, Lld, Target, TargetMetadata, base}; +use crate::spec::{Arch, Cc, LinkerFlavor, Lld, Target, TargetMetadata, base}; pub(crate) fn target() -> Target { let mut base = base::helenos::opts(); @@ -20,7 +20,7 @@ pub(crate) fn target() -> Target { }, pointer_width: 64, data_layout: "E-m:e-i64:64-i128:128-n32:64-S128".into(), - arch: "sparc64".into(), + arch: Arch::Sparc64, options: base, } } diff --git a/compiler/rustc_target/src/spec/targets/sparc64_unknown_linux_gnu.rs b/compiler/rustc_target/src/spec/targets/sparc64_unknown_linux_gnu.rs index a52dadba5a51d..b6c06af3cc835 100644 --- a/compiler/rustc_target/src/spec/targets/sparc64_unknown_linux_gnu.rs +++ b/compiler/rustc_target/src/spec/targets/sparc64_unknown_linux_gnu.rs @@ -1,6 +1,6 @@ use rustc_abi::Endian; -use crate::spec::{Target, TargetMetadata, base}; +use crate::spec::{Arch, Target, TargetMetadata, base}; pub(crate) fn target() -> Target { let mut base = base::linux_gnu::opts(); @@ -18,7 +18,7 @@ pub(crate) fn target() -> Target { }, pointer_width: 64, data_layout: "E-m:e-i64:64-i128:128-n32:64-S128".into(), - arch: "sparc64".into(), + arch: Arch::Sparc64, options: base, } } diff --git a/compiler/rustc_target/src/spec/targets/sparc64_unknown_netbsd.rs b/compiler/rustc_target/src/spec/targets/sparc64_unknown_netbsd.rs index 21eedc5b6bc0a..8f95528893100 100644 --- a/compiler/rustc_target/src/spec/targets/sparc64_unknown_netbsd.rs +++ b/compiler/rustc_target/src/spec/targets/sparc64_unknown_netbsd.rs @@ -1,6 +1,6 @@ use rustc_abi::Endian; -use crate::spec::{Cc, LinkerFlavor, Lld, Target, TargetMetadata, TargetOptions, base}; +use crate::spec::{Arch, Cc, LinkerFlavor, Lld, Target, TargetMetadata, TargetOptions, base}; pub(crate) fn target() -> Target { let mut base = base::netbsd::opts(); @@ -18,7 +18,7 @@ pub(crate) fn target() -> Target { }, pointer_width: 64, data_layout: "E-m:e-i64:64-i128:128-n32:64-S128".into(), - arch: "sparc64".into(), + arch: Arch::Sparc64, options: TargetOptions { endian: Endian::Big, mcount: "__mcount".into(), ..base }, } } diff --git a/compiler/rustc_target/src/spec/targets/sparc64_unknown_openbsd.rs b/compiler/rustc_target/src/spec/targets/sparc64_unknown_openbsd.rs index b573bdf80a96a..6adabeca4a8be 100644 --- a/compiler/rustc_target/src/spec/targets/sparc64_unknown_openbsd.rs +++ b/compiler/rustc_target/src/spec/targets/sparc64_unknown_openbsd.rs @@ -1,6 +1,6 @@ use rustc_abi::Endian; -use crate::spec::{Cc, LinkerFlavor, Lld, Target, TargetMetadata, base}; +use crate::spec::{Arch, Cc, LinkerFlavor, Lld, Target, TargetMetadata, base}; pub(crate) fn target() -> Target { let mut base = base::openbsd::opts(); @@ -19,7 +19,7 @@ pub(crate) fn target() -> Target { }, pointer_width: 64, data_layout: "E-m:e-i64:64-i128:128-n32:64-S128".into(), - arch: "sparc64".into(), + arch: Arch::Sparc64, options: base, } } diff --git a/compiler/rustc_target/src/spec/targets/sparc_unknown_linux_gnu.rs b/compiler/rustc_target/src/spec/targets/sparc_unknown_linux_gnu.rs index ffef696791256..f110acf63d876 100644 --- a/compiler/rustc_target/src/spec/targets/sparc_unknown_linux_gnu.rs +++ b/compiler/rustc_target/src/spec/targets/sparc_unknown_linux_gnu.rs @@ -1,6 +1,6 @@ use rustc_abi::Endian; -use crate::spec::{Cc, LinkerFlavor, Lld, Target, TargetMetadata, TargetOptions, base}; +use crate::spec::{Arch, Cc, LinkerFlavor, Lld, Target, TargetMetadata, TargetOptions, base}; pub(crate) fn target() -> Target { Target { @@ -13,7 +13,7 @@ pub(crate) fn target() -> Target { }, pointer_width: 32, data_layout: "E-m:e-p:32:32-i64:64-i128:128-f128:64-n32-S64".into(), - arch: "sparc".into(), + arch: Arch::Sparc, options: TargetOptions { features: "+v8plus".into(), cpu: "v9".into(), diff --git a/compiler/rustc_target/src/spec/targets/sparc_unknown_none_elf.rs b/compiler/rustc_target/src/spec/targets/sparc_unknown_none_elf.rs index c2f64998dddb9..de6063301f68b 100644 --- a/compiler/rustc_target/src/spec/targets/sparc_unknown_none_elf.rs +++ b/compiler/rustc_target/src/spec/targets/sparc_unknown_none_elf.rs @@ -1,7 +1,7 @@ use rustc_abi::Endian; use crate::spec::{ - Cc, LinkerFlavor, Lld, PanicStrategy, RelocModel, Target, TargetMetadata, TargetOptions, + Arch, Cc, LinkerFlavor, Lld, PanicStrategy, RelocModel, Target, TargetMetadata, TargetOptions, }; pub(crate) fn target() -> Target { @@ -29,7 +29,7 @@ pub(crate) fn target() -> Target { std: Some(false), }, pointer_width: 32, - arch: "sparc".into(), + arch: Arch::Sparc, options, } } diff --git a/compiler/rustc_target/src/spec/targets/sparcv9_sun_solaris.rs b/compiler/rustc_target/src/spec/targets/sparcv9_sun_solaris.rs index 1c53e15837cff..79035c791156d 100644 --- a/compiler/rustc_target/src/spec/targets/sparcv9_sun_solaris.rs +++ b/compiler/rustc_target/src/spec/targets/sparcv9_sun_solaris.rs @@ -1,6 +1,6 @@ use rustc_abi::Endian; -use crate::spec::{Cc, LinkerFlavor, Target, TargetMetadata, base}; +use crate::spec::{Arch, Cc, LinkerFlavor, Target, TargetMetadata, base}; pub(crate) fn target() -> Target { let mut base = base::solaris::opts(); @@ -25,7 +25,7 @@ pub(crate) fn target() -> Target { // used widely in the source base. If we ever needed ABI // differentiation from the sparc64, we could, but that would probably // just be confusing. - arch: "sparc64".into(), + arch: Arch::Sparc64, options: base, } } diff --git a/compiler/rustc_target/src/spec/targets/thumbv4t_none_eabi.rs b/compiler/rustc_target/src/spec/targets/thumbv4t_none_eabi.rs index 7221bd8d4aef3..7a183bf5414e8 100644 --- a/compiler/rustc_target/src/spec/targets/thumbv4t_none_eabi.rs +++ b/compiler/rustc_target/src/spec/targets/thumbv4t_none_eabi.rs @@ -10,8 +10,8 @@ //! `-Clink-arg=-Tmy_script.ld` to override that with a correct linker script. use crate::spec::{ - FloatAbi, FramePointer, PanicStrategy, RelocModel, Target, TargetMetadata, TargetOptions, base, - cvs, + Arch, FloatAbi, FramePointer, PanicStrategy, RelocModel, Target, TargetMetadata, TargetOptions, + base, cvs, }; pub(crate) fn target() -> Target { @@ -24,7 +24,7 @@ pub(crate) fn target() -> Target { std: Some(false), }, pointer_width: 32, - arch: "arm".into(), + arch: Arch::Arm, /* Data layout args are '-' separated: * little endian * stack is 64-bit aligned (EABI) diff --git a/compiler/rustc_target/src/spec/targets/thumbv5te_none_eabi.rs b/compiler/rustc_target/src/spec/targets/thumbv5te_none_eabi.rs index 155e25211c1f9..b20be27665e00 100644 --- a/compiler/rustc_target/src/spec/targets/thumbv5te_none_eabi.rs +++ b/compiler/rustc_target/src/spec/targets/thumbv5te_none_eabi.rs @@ -1,6 +1,6 @@ //! Targets the ARMv5TE, with code as `t32` code by default. -use crate::spec::{FloatAbi, FramePointer, Target, TargetMetadata, TargetOptions, base, cvs}; +use crate::spec::{Arch, FloatAbi, FramePointer, Target, TargetMetadata, TargetOptions, base, cvs}; pub(crate) fn target() -> Target { Target { @@ -12,7 +12,7 @@ pub(crate) fn target() -> Target { std: Some(false), }, pointer_width: 32, - arch: "arm".into(), + arch: Arch::Arm, /* Data layout args are '-' separated: * little endian * stack is 64-bit aligned (EABI) diff --git a/compiler/rustc_target/src/spec/targets/thumbv6m_none_eabi.rs b/compiler/rustc_target/src/spec/targets/thumbv6m_none_eabi.rs index 3b4b94da0577e..684e465af4a66 100644 --- a/compiler/rustc_target/src/spec/targets/thumbv6m_none_eabi.rs +++ b/compiler/rustc_target/src/spec/targets/thumbv6m_none_eabi.rs @@ -1,6 +1,6 @@ // Targets the Cortex-M0, Cortex-M0+ and Cortex-M1 processors (ARMv6-M architecture) -use crate::spec::{FloatAbi, Target, TargetMetadata, TargetOptions, base}; +use crate::spec::{Arch, FloatAbi, Target, TargetMetadata, TargetOptions, base}; pub(crate) fn target() -> Target { Target { @@ -13,7 +13,7 @@ pub(crate) fn target() -> Target { }, pointer_width: 32, data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(), - arch: "arm".into(), + arch: Arch::Arm, options: TargetOptions { abi: "eabi".into(), diff --git a/compiler/rustc_target/src/spec/targets/thumbv6m_nuttx_eabi.rs b/compiler/rustc_target/src/spec/targets/thumbv6m_nuttx_eabi.rs index 3c6133dc7ceb0..c0dd931e66a47 100644 --- a/compiler/rustc_target/src/spec/targets/thumbv6m_nuttx_eabi.rs +++ b/compiler/rustc_target/src/spec/targets/thumbv6m_nuttx_eabi.rs @@ -1,6 +1,6 @@ // Targets the Cortex-M0, Cortex-M0+ and Cortex-M1 processors (ARMv6-M architecture) -use crate::spec::{FloatAbi, Target, TargetMetadata, TargetOptions, base, cvs}; +use crate::spec::{Arch, FloatAbi, Target, TargetMetadata, TargetOptions, base, cvs}; pub(crate) fn target() -> Target { Target { @@ -13,7 +13,7 @@ pub(crate) fn target() -> Target { }, pointer_width: 32, data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(), - arch: "arm".into(), + arch: Arch::Arm, options: TargetOptions { families: cvs!["unix"], diff --git a/compiler/rustc_target/src/spec/targets/thumbv7a_nuttx_eabi.rs b/compiler/rustc_target/src/spec/targets/thumbv7a_nuttx_eabi.rs index 5660f97c8b57b..335c4c1af5103 100644 --- a/compiler/rustc_target/src/spec/targets/thumbv7a_nuttx_eabi.rs +++ b/compiler/rustc_target/src/spec/targets/thumbv7a_nuttx_eabi.rs @@ -4,7 +4,7 @@ // and will use software floating point operations. This matches the NuttX EABI // configuration without hardware floating point support. -use crate::spec::{FloatAbi, Target, TargetMetadata, TargetOptions, base, cvs}; +use crate::spec::{Arch, FloatAbi, Target, TargetMetadata, TargetOptions, base, cvs}; pub(crate) fn target() -> Target { Target { @@ -17,7 +17,7 @@ pub(crate) fn target() -> Target { }, pointer_width: 32, data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(), - arch: "arm".into(), + arch: Arch::Arm, options: TargetOptions { families: cvs!["unix"], diff --git a/compiler/rustc_target/src/spec/targets/thumbv7a_nuttx_eabihf.rs b/compiler/rustc_target/src/spec/targets/thumbv7a_nuttx_eabihf.rs index d79970b0a0dd7..0a0dbaf125545 100644 --- a/compiler/rustc_target/src/spec/targets/thumbv7a_nuttx_eabihf.rs +++ b/compiler/rustc_target/src/spec/targets/thumbv7a_nuttx_eabihf.rs @@ -7,7 +7,7 @@ // This target uses the "hard" floating convention (ABI) where floating point values // are passed to/from subroutines via FPU registers (S0, S1, D0, D1, etc.). -use crate::spec::{FloatAbi, Target, TargetMetadata, TargetOptions, base, cvs}; +use crate::spec::{Arch, FloatAbi, Target, TargetMetadata, TargetOptions, base, cvs}; pub(crate) fn target() -> Target { Target { @@ -20,7 +20,7 @@ pub(crate) fn target() -> Target { }, pointer_width: 32, data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(), - arch: "arm".into(), + arch: Arch::Arm, options: TargetOptions { families: cvs!["unix"], diff --git a/compiler/rustc_target/src/spec/targets/thumbv7a_pc_windows_msvc.rs b/compiler/rustc_target/src/spec/targets/thumbv7a_pc_windows_msvc.rs index 33da885cc1a53..808fae366835b 100644 --- a/compiler/rustc_target/src/spec/targets/thumbv7a_pc_windows_msvc.rs +++ b/compiler/rustc_target/src/spec/targets/thumbv7a_pc_windows_msvc.rs @@ -1,5 +1,5 @@ use crate::spec::{ - FloatAbi, LinkerFlavor, Lld, PanicStrategy, Target, TargetMetadata, TargetOptions, base, + Arch, FloatAbi, LinkerFlavor, Lld, PanicStrategy, Target, TargetMetadata, TargetOptions, base, }; pub(crate) fn target() -> Target { @@ -23,7 +23,7 @@ pub(crate) fn target() -> Target { }, pointer_width: 32, data_layout: "e-m:w-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(), - arch: "arm".into(), + arch: Arch::Arm, options: TargetOptions { llvm_floatabi: Some(FloatAbi::Hard), features: "+vfp3,+neon".into(), diff --git a/compiler/rustc_target/src/spec/targets/thumbv7a_uwp_windows_msvc.rs b/compiler/rustc_target/src/spec/targets/thumbv7a_uwp_windows_msvc.rs index b4cc960939e9d..d9ad392fc814e 100644 --- a/compiler/rustc_target/src/spec/targets/thumbv7a_uwp_windows_msvc.rs +++ b/compiler/rustc_target/src/spec/targets/thumbv7a_uwp_windows_msvc.rs @@ -1,4 +1,4 @@ -use crate::spec::{FloatAbi, PanicStrategy, Target, TargetMetadata, TargetOptions, base}; +use crate::spec::{Arch, FloatAbi, PanicStrategy, Target, TargetMetadata, TargetOptions, base}; pub(crate) fn target() -> Target { Target { @@ -11,7 +11,7 @@ pub(crate) fn target() -> Target { }, pointer_width: 32, data_layout: "e-m:w-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(), - arch: "arm".into(), + arch: Arch::Arm, options: TargetOptions { llvm_floatabi: Some(FloatAbi::Hard), features: "+vfp3,+neon".into(), diff --git a/compiler/rustc_target/src/spec/targets/thumbv7em_none_eabi.rs b/compiler/rustc_target/src/spec/targets/thumbv7em_none_eabi.rs index c747d721b671f..c67e955d0856b 100644 --- a/compiler/rustc_target/src/spec/targets/thumbv7em_none_eabi.rs +++ b/compiler/rustc_target/src/spec/targets/thumbv7em_none_eabi.rs @@ -9,7 +9,7 @@ // To opt-in to hardware accelerated floating point operations, you can use, for example, // `-C target-feature=+vfp4` or `-C target-cpu=cortex-m4`. -use crate::spec::{FloatAbi, Target, TargetMetadata, TargetOptions, base}; +use crate::spec::{Arch, FloatAbi, Target, TargetMetadata, TargetOptions, base}; pub(crate) fn target() -> Target { Target { @@ -22,7 +22,7 @@ pub(crate) fn target() -> Target { }, pointer_width: 32, data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(), - arch: "arm".into(), + arch: Arch::Arm, options: TargetOptions { abi: "eabi".into(), diff --git a/compiler/rustc_target/src/spec/targets/thumbv7em_none_eabihf.rs b/compiler/rustc_target/src/spec/targets/thumbv7em_none_eabihf.rs index 309d32042a036..9a05209b0eb65 100644 --- a/compiler/rustc_target/src/spec/targets/thumbv7em_none_eabihf.rs +++ b/compiler/rustc_target/src/spec/targets/thumbv7em_none_eabihf.rs @@ -8,7 +8,7 @@ // // To opt into double precision hardware support, use the `-C target-feature=+fp64` flag. -use crate::spec::{FloatAbi, Target, TargetMetadata, TargetOptions, base}; +use crate::spec::{Arch, FloatAbi, Target, TargetMetadata, TargetOptions, base}; pub(crate) fn target() -> Target { Target { @@ -21,7 +21,7 @@ pub(crate) fn target() -> Target { }, pointer_width: 32, data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(), - arch: "arm".into(), + arch: Arch::Arm, options: TargetOptions { abi: "eabihf".into(), diff --git a/compiler/rustc_target/src/spec/targets/thumbv7em_nuttx_eabi.rs b/compiler/rustc_target/src/spec/targets/thumbv7em_nuttx_eabi.rs index 57ef4e75e6408..7888587ce9e34 100644 --- a/compiler/rustc_target/src/spec/targets/thumbv7em_nuttx_eabi.rs +++ b/compiler/rustc_target/src/spec/targets/thumbv7em_nuttx_eabi.rs @@ -9,7 +9,7 @@ // To opt-in to hardware accelerated floating point operations, you can use, for example, // `-C target-feature=+vfp4` or `-C target-cpu=cortex-m4`. -use crate::spec::{FloatAbi, Target, TargetMetadata, TargetOptions, base, cvs}; +use crate::spec::{Arch, FloatAbi, Target, TargetMetadata, TargetOptions, base, cvs}; pub(crate) fn target() -> Target { Target { @@ -22,7 +22,7 @@ pub(crate) fn target() -> Target { }, pointer_width: 32, data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(), - arch: "arm".into(), + arch: Arch::Arm, options: TargetOptions { families: cvs!["unix"], diff --git a/compiler/rustc_target/src/spec/targets/thumbv7em_nuttx_eabihf.rs b/compiler/rustc_target/src/spec/targets/thumbv7em_nuttx_eabihf.rs index 0518872dd62d2..51e57f77963af 100644 --- a/compiler/rustc_target/src/spec/targets/thumbv7em_nuttx_eabihf.rs +++ b/compiler/rustc_target/src/spec/targets/thumbv7em_nuttx_eabihf.rs @@ -8,7 +8,7 @@ // // To opt into double precision hardware support, use the `-C target-feature=+fp64` flag. -use crate::spec::{FloatAbi, Target, TargetMetadata, TargetOptions, base, cvs}; +use crate::spec::{Arch, FloatAbi, Target, TargetMetadata, TargetOptions, base, cvs}; pub(crate) fn target() -> Target { Target { @@ -21,7 +21,7 @@ pub(crate) fn target() -> Target { }, pointer_width: 32, data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(), - arch: "arm".into(), + arch: Arch::Arm, options: TargetOptions { families: cvs!["unix"], diff --git a/compiler/rustc_target/src/spec/targets/thumbv7m_none_eabi.rs b/compiler/rustc_target/src/spec/targets/thumbv7m_none_eabi.rs index f261009d854e8..fea5f15fe0a60 100644 --- a/compiler/rustc_target/src/spec/targets/thumbv7m_none_eabi.rs +++ b/compiler/rustc_target/src/spec/targets/thumbv7m_none_eabi.rs @@ -1,6 +1,6 @@ // Targets the Cortex-M3 processor (ARMv7-M) -use crate::spec::{FloatAbi, Target, TargetMetadata, TargetOptions, base}; +use crate::spec::{Arch, FloatAbi, Target, TargetMetadata, TargetOptions, base}; pub(crate) fn target() -> Target { Target { @@ -13,7 +13,7 @@ pub(crate) fn target() -> Target { }, pointer_width: 32, data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(), - arch: "arm".into(), + arch: Arch::Arm, options: TargetOptions { abi: "eabi".into(), diff --git a/compiler/rustc_target/src/spec/targets/thumbv7m_nuttx_eabi.rs b/compiler/rustc_target/src/spec/targets/thumbv7m_nuttx_eabi.rs index 611795e58f1f9..50ab8c5a4ee0b 100644 --- a/compiler/rustc_target/src/spec/targets/thumbv7m_nuttx_eabi.rs +++ b/compiler/rustc_target/src/spec/targets/thumbv7m_nuttx_eabi.rs @@ -1,6 +1,6 @@ // Targets the Cortex-M3 processor (ARMv7-M) -use crate::spec::{FloatAbi, Target, TargetMetadata, TargetOptions, base, cvs}; +use crate::spec::{Arch, FloatAbi, Target, TargetMetadata, TargetOptions, base, cvs}; pub(crate) fn target() -> Target { Target { @@ -13,7 +13,7 @@ pub(crate) fn target() -> Target { }, pointer_width: 32, data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(), - arch: "arm".into(), + arch: Arch::Arm, options: TargetOptions { families: cvs!["unix"], diff --git a/compiler/rustc_target/src/spec/targets/thumbv7neon_linux_androideabi.rs b/compiler/rustc_target/src/spec/targets/thumbv7neon_linux_androideabi.rs index d3a25163c53fd..cc6f26d38deaa 100644 --- a/compiler/rustc_target/src/spec/targets/thumbv7neon_linux_androideabi.rs +++ b/compiler/rustc_target/src/spec/targets/thumbv7neon_linux_androideabi.rs @@ -1,4 +1,6 @@ -use crate::spec::{Cc, FloatAbi, LinkerFlavor, Lld, Target, TargetMetadata, TargetOptions, base}; +use crate::spec::{ + Arch, Cc, FloatAbi, LinkerFlavor, Lld, Target, TargetMetadata, TargetOptions, base, +}; // This target if is for the Android v7a ABI in thumb mode with // NEON unconditionally enabled and, therefore, with 32 FPU registers @@ -21,7 +23,7 @@ pub(crate) fn target() -> Target { }, pointer_width: 32, data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(), - arch: "arm".into(), + arch: Arch::Arm, options: TargetOptions { abi: "eabi".into(), llvm_floatabi: Some(FloatAbi::Soft), diff --git a/compiler/rustc_target/src/spec/targets/thumbv7neon_unknown_linux_gnueabihf.rs b/compiler/rustc_target/src/spec/targets/thumbv7neon_unknown_linux_gnueabihf.rs index cce49f274aca7..9abbec824b0f2 100644 --- a/compiler/rustc_target/src/spec/targets/thumbv7neon_unknown_linux_gnueabihf.rs +++ b/compiler/rustc_target/src/spec/targets/thumbv7neon_unknown_linux_gnueabihf.rs @@ -1,4 +1,4 @@ -use crate::spec::{FloatAbi, Target, TargetMetadata, TargetOptions, base}; +use crate::spec::{Arch, FloatAbi, Target, TargetMetadata, TargetOptions, base}; // This target is for glibc Linux on ARMv7 with thumb mode enabled // (for consistency with Android and Debian-based distributions) @@ -19,7 +19,7 @@ pub(crate) fn target() -> Target { }, pointer_width: 32, data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(), - arch: "arm".into(), + arch: Arch::Arm, options: TargetOptions { abi: "eabihf".into(), llvm_floatabi: Some(FloatAbi::Hard), diff --git a/compiler/rustc_target/src/spec/targets/thumbv7neon_unknown_linux_musleabihf.rs b/compiler/rustc_target/src/spec/targets/thumbv7neon_unknown_linux_musleabihf.rs index d58339bc38c29..e8239172409b0 100644 --- a/compiler/rustc_target/src/spec/targets/thumbv7neon_unknown_linux_musleabihf.rs +++ b/compiler/rustc_target/src/spec/targets/thumbv7neon_unknown_linux_musleabihf.rs @@ -1,4 +1,4 @@ -use crate::spec::{FloatAbi, Target, TargetMetadata, TargetOptions, base}; +use crate::spec::{Arch, FloatAbi, Target, TargetMetadata, TargetOptions, base}; // This target is for musl Linux on ARMv7 with thumb mode enabled // (for consistency with Android and Debian-based distributions) @@ -17,7 +17,7 @@ pub(crate) fn target() -> Target { }, pointer_width: 32, data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(), - arch: "arm".into(), + arch: Arch::Arm, // Most of these settings are copied from the thumbv7neon_unknown_linux_gnueabihf // target. diff --git a/compiler/rustc_target/src/spec/targets/thumbv8m_base_none_eabi.rs b/compiler/rustc_target/src/spec/targets/thumbv8m_base_none_eabi.rs index b35f7bac93b4a..aca7441d34abc 100644 --- a/compiler/rustc_target/src/spec/targets/thumbv8m_base_none_eabi.rs +++ b/compiler/rustc_target/src/spec/targets/thumbv8m_base_none_eabi.rs @@ -1,6 +1,6 @@ // Targets the Cortex-M23 processor (Baseline ARMv8-M) -use crate::spec::{FloatAbi, Target, TargetMetadata, TargetOptions, base}; +use crate::spec::{Arch, FloatAbi, Target, TargetMetadata, TargetOptions, base}; pub(crate) fn target() -> Target { Target { @@ -13,7 +13,7 @@ pub(crate) fn target() -> Target { }, pointer_width: 32, data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(), - arch: "arm".into(), + arch: Arch::Arm, options: TargetOptions { abi: "eabi".into(), diff --git a/compiler/rustc_target/src/spec/targets/thumbv8m_base_nuttx_eabi.rs b/compiler/rustc_target/src/spec/targets/thumbv8m_base_nuttx_eabi.rs index 4e5f6898651af..26bf14d176ba8 100644 --- a/compiler/rustc_target/src/spec/targets/thumbv8m_base_nuttx_eabi.rs +++ b/compiler/rustc_target/src/spec/targets/thumbv8m_base_nuttx_eabi.rs @@ -1,6 +1,6 @@ // Targets the Cortex-M23 processor (Baseline ARMv8-M) -use crate::spec::{FloatAbi, Target, TargetMetadata, TargetOptions, base, cvs}; +use crate::spec::{Arch, FloatAbi, Target, TargetMetadata, TargetOptions, base, cvs}; pub(crate) fn target() -> Target { Target { @@ -13,7 +13,7 @@ pub(crate) fn target() -> Target { }, pointer_width: 32, data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(), - arch: "arm".into(), + arch: Arch::Arm, options: TargetOptions { families: cvs!["unix"], diff --git a/compiler/rustc_target/src/spec/targets/thumbv8m_main_none_eabi.rs b/compiler/rustc_target/src/spec/targets/thumbv8m_main_none_eabi.rs index 38143904efd14..e1cc16aeb5c6b 100644 --- a/compiler/rustc_target/src/spec/targets/thumbv8m_main_none_eabi.rs +++ b/compiler/rustc_target/src/spec/targets/thumbv8m_main_none_eabi.rs @@ -1,7 +1,7 @@ // Targets the Cortex-M33 processor (Armv8-M Mainline architecture profile), // without the Floating Point extension. -use crate::spec::{FloatAbi, Target, TargetMetadata, TargetOptions, base}; +use crate::spec::{Arch, FloatAbi, Target, TargetMetadata, TargetOptions, base}; pub(crate) fn target() -> Target { Target { @@ -14,7 +14,7 @@ pub(crate) fn target() -> Target { }, pointer_width: 32, data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(), - arch: "arm".into(), + arch: Arch::Arm, options: TargetOptions { abi: "eabi".into(), diff --git a/compiler/rustc_target/src/spec/targets/thumbv8m_main_none_eabihf.rs b/compiler/rustc_target/src/spec/targets/thumbv8m_main_none_eabihf.rs index 55b7561da84c7..cd3d3327a5c45 100644 --- a/compiler/rustc_target/src/spec/targets/thumbv8m_main_none_eabihf.rs +++ b/compiler/rustc_target/src/spec/targets/thumbv8m_main_none_eabihf.rs @@ -1,7 +1,7 @@ // Targets the Cortex-M33 processor (Armv8-M Mainline architecture profile), // with the Floating Point extension. -use crate::spec::{FloatAbi, Target, TargetMetadata, TargetOptions, base}; +use crate::spec::{Arch, FloatAbi, Target, TargetMetadata, TargetOptions, base}; pub(crate) fn target() -> Target { Target { @@ -14,7 +14,7 @@ pub(crate) fn target() -> Target { }, pointer_width: 32, data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(), - arch: "arm".into(), + arch: Arch::Arm, options: TargetOptions { abi: "eabihf".into(), diff --git a/compiler/rustc_target/src/spec/targets/thumbv8m_main_nuttx_eabi.rs b/compiler/rustc_target/src/spec/targets/thumbv8m_main_nuttx_eabi.rs index 56aca0a882977..1fae7a92d9235 100644 --- a/compiler/rustc_target/src/spec/targets/thumbv8m_main_nuttx_eabi.rs +++ b/compiler/rustc_target/src/spec/targets/thumbv8m_main_nuttx_eabi.rs @@ -1,7 +1,7 @@ // Targets the Cortex-M33 processor (Armv8-M Mainline architecture profile), // without the Floating Point extension. -use crate::spec::{FloatAbi, Target, TargetMetadata, TargetOptions, base, cvs}; +use crate::spec::{Arch, FloatAbi, Target, TargetMetadata, TargetOptions, base, cvs}; pub(crate) fn target() -> Target { Target { @@ -14,7 +14,7 @@ pub(crate) fn target() -> Target { }, pointer_width: 32, data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(), - arch: "arm".into(), + arch: Arch::Arm, options: TargetOptions { families: cvs!["unix"], diff --git a/compiler/rustc_target/src/spec/targets/thumbv8m_main_nuttx_eabihf.rs b/compiler/rustc_target/src/spec/targets/thumbv8m_main_nuttx_eabihf.rs index 47525e704daf6..b8de91edfb23e 100644 --- a/compiler/rustc_target/src/spec/targets/thumbv8m_main_nuttx_eabihf.rs +++ b/compiler/rustc_target/src/spec/targets/thumbv8m_main_nuttx_eabihf.rs @@ -1,7 +1,7 @@ // Targets the Cortex-M33 processor (Armv8-M Mainline architecture profile), // with the Floating Point extension. -use crate::spec::{FloatAbi, Target, TargetMetadata, TargetOptions, base, cvs}; +use crate::spec::{Arch, FloatAbi, Target, TargetMetadata, TargetOptions, base, cvs}; pub(crate) fn target() -> Target { Target { @@ -14,7 +14,7 @@ pub(crate) fn target() -> Target { }, pointer_width: 32, data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(), - arch: "arm".into(), + arch: Arch::Arm, options: TargetOptions { families: cvs!["unix"], diff --git a/compiler/rustc_target/src/spec/targets/wasm32_unknown_emscripten.rs b/compiler/rustc_target/src/spec/targets/wasm32_unknown_emscripten.rs index 4624c0fd5cba9..aa4a1be992916 100644 --- a/compiler/rustc_target/src/spec/targets/wasm32_unknown_emscripten.rs +++ b/compiler/rustc_target/src/spec/targets/wasm32_unknown_emscripten.rs @@ -1,6 +1,6 @@ use crate::spec::{ - LinkArgs, LinkerFlavor, PanicStrategy, RelocModel, Target, TargetMetadata, TargetOptions, base, - cvs, + Arch, LinkArgs, LinkerFlavor, PanicStrategy, RelocModel, Target, TargetMetadata, TargetOptions, + base, cvs, }; pub(crate) fn target() -> Target { @@ -35,7 +35,7 @@ pub(crate) fn target() -> Target { pointer_width: 32, data_layout: "e-m:e-p:32:32-p10:8:8-p20:8:8-i64:64-i128:128-f128:64-n32:64-S128-ni:1:10:20" .into(), - arch: "wasm32".into(), + arch: Arch::Wasm32, options: opts, } } diff --git a/compiler/rustc_target/src/spec/targets/wasm32_unknown_unknown.rs b/compiler/rustc_target/src/spec/targets/wasm32_unknown_unknown.rs index b5792731a900d..3050f17d5efbb 100644 --- a/compiler/rustc_target/src/spec/targets/wasm32_unknown_unknown.rs +++ b/compiler/rustc_target/src/spec/targets/wasm32_unknown_unknown.rs @@ -10,7 +10,7 @@ //! This target is more or less managed by the Rust and WebAssembly Working //! Group nowadays at . -use crate::spec::{Cc, LinkerFlavor, Target, TargetMetadata, base}; +use crate::spec::{Arch, Cc, LinkerFlavor, Target, TargetMetadata, base}; pub(crate) fn target() -> Target { let mut options = base::wasm::options(); @@ -44,7 +44,7 @@ pub(crate) fn target() -> Target { }, pointer_width: 32, data_layout: "e-m:e-p:32:32-p10:8:8-p20:8:8-i64:64-i128:128-n32:64-S128-ni:1:10:20".into(), - arch: "wasm32".into(), + arch: Arch::Wasm32, options, } } diff --git a/compiler/rustc_target/src/spec/targets/wasm32_wali_linux_musl.rs b/compiler/rustc_target/src/spec/targets/wasm32_wali_linux_musl.rs index 06e5cfaed92da..9e4121d97eb8d 100644 --- a/compiler/rustc_target/src/spec/targets/wasm32_wali_linux_musl.rs +++ b/compiler/rustc_target/src/spec/targets/wasm32_wali_linux_musl.rs @@ -1,7 +1,7 @@ //! The `wasm32-wali-linux-musl` target is a wasm32 target compliant with the //! [WebAssembly Linux Interface](https://github.com/arjunr2/WALI). -use crate::spec::{Cc, LinkerFlavor, Target, TargetMetadata, base}; +use crate::spec::{Arch, Cc, LinkerFlavor, Target, TargetMetadata, base}; pub(crate) fn target() -> Target { let mut options = base::linux_wasm::opts(); @@ -30,7 +30,7 @@ pub(crate) fn target() -> Target { }, pointer_width: 32, data_layout: "e-m:e-p:32:32-p10:8:8-p20:8:8-i64:64-i128:128-n32:64-S128-ni:1:10:20".into(), - arch: "wasm32".into(), + arch: Arch::Wasm32, options, } } diff --git a/compiler/rustc_target/src/spec/targets/wasm32_wasip1.rs b/compiler/rustc_target/src/spec/targets/wasm32_wasip1.rs index 26add451ed253..a7c196c4530f0 100644 --- a/compiler/rustc_target/src/spec/targets/wasm32_wasip1.rs +++ b/compiler/rustc_target/src/spec/targets/wasm32_wasip1.rs @@ -11,7 +11,7 @@ //! introduced. use crate::spec::{ - Cc, LinkSelfContainedDefault, LinkerFlavor, Target, TargetMetadata, base, crt_objects, + Arch, Cc, LinkSelfContainedDefault, LinkerFlavor, Target, TargetMetadata, base, crt_objects, }; pub(crate) fn target() -> Target { @@ -58,7 +58,7 @@ pub(crate) fn target() -> Target { }, pointer_width: 32, data_layout: "e-m:e-p:32:32-p10:8:8-p20:8:8-i64:64-i128:128-n32:64-S128-ni:1:10:20".into(), - arch: "wasm32".into(), + arch: Arch::Wasm32, options, } } diff --git a/compiler/rustc_target/src/spec/targets/wasm32_wasip1_threads.rs b/compiler/rustc_target/src/spec/targets/wasm32_wasip1_threads.rs index c735c72cb1cb1..d4953cc9d4982 100644 --- a/compiler/rustc_target/src/spec/targets/wasm32_wasip1_threads.rs +++ b/compiler/rustc_target/src/spec/targets/wasm32_wasip1_threads.rs @@ -8,7 +8,7 @@ //! Historically this target was known as `wasm32-wasi-preview1-threads`. use crate::spec::{ - Cc, LinkSelfContainedDefault, LinkerFlavor, Target, TargetMetadata, base, crt_objects, + Arch, Cc, LinkSelfContainedDefault, LinkerFlavor, Target, TargetMetadata, base, crt_objects, }; pub(crate) fn target() -> Target { @@ -72,7 +72,7 @@ pub(crate) fn target() -> Target { }, pointer_width: 32, data_layout: "e-m:e-p:32:32-p10:8:8-p20:8:8-i64:64-i128:128-n32:64-S128-ni:1:10:20".into(), - arch: "wasm32".into(), + arch: Arch::Wasm32, options, } } diff --git a/compiler/rustc_target/src/spec/targets/wasm32_wasip2.rs b/compiler/rustc_target/src/spec/targets/wasm32_wasip2.rs index 7ad675dc3cf13..717d49004a175 100644 --- a/compiler/rustc_target/src/spec/targets/wasm32_wasip2.rs +++ b/compiler/rustc_target/src/spec/targets/wasm32_wasip2.rs @@ -17,7 +17,7 @@ //! . use crate::spec::{ - LinkSelfContainedDefault, RelocModel, Target, TargetMetadata, base, crt_objects, + Arch, LinkSelfContainedDefault, RelocModel, Target, TargetMetadata, base, crt_objects, }; pub(crate) fn target() -> Target { @@ -69,7 +69,7 @@ pub(crate) fn target() -> Target { }, pointer_width: 32, data_layout: "e-m:e-p:32:32-p10:8:8-p20:8:8-i64:64-i128:128-n32:64-S128-ni:1:10:20".into(), - arch: "wasm32".into(), + arch: Arch::Wasm32, options, } } diff --git a/compiler/rustc_target/src/spec/targets/wasm32v1_none.rs b/compiler/rustc_target/src/spec/targets/wasm32v1_none.rs index e554e2ac07680..41267f0e5708f 100644 --- a/compiler/rustc_target/src/spec/targets/wasm32v1_none.rs +++ b/compiler/rustc_target/src/spec/targets/wasm32v1_none.rs @@ -12,7 +12,7 @@ //! nightly Rust feature `-Zbuild-std`. This target is for people who want to //! use stable Rust, and target a stable set pf WebAssembly features. -use crate::spec::{Cc, LinkerFlavor, Target, TargetMetadata, base}; +use crate::spec::{Arch, Cc, LinkerFlavor, Target, TargetMetadata, base}; pub(crate) fn target() -> Target { let mut options = base::wasm::options(); @@ -51,7 +51,7 @@ pub(crate) fn target() -> Target { }, pointer_width: 32, data_layout: "e-m:e-p:32:32-p10:8:8-p20:8:8-i64:64-i128:128-n32:64-S128-ni:1:10:20".into(), - arch: "wasm32".into(), + arch: Arch::Wasm32, options, } } diff --git a/compiler/rustc_target/src/spec/targets/wasm64_unknown_unknown.rs b/compiler/rustc_target/src/spec/targets/wasm64_unknown_unknown.rs index e8ac93a87ca47..850e85591661d 100644 --- a/compiler/rustc_target/src/spec/targets/wasm64_unknown_unknown.rs +++ b/compiler/rustc_target/src/spec/targets/wasm64_unknown_unknown.rs @@ -7,7 +7,7 @@ //! the standard library is available, most of it returns an error immediately //! (e.g. trying to create a TCP stream or something like that). -use crate::spec::{Cc, LinkerFlavor, Target, TargetMetadata, base}; +use crate::spec::{Arch, Cc, LinkerFlavor, Target, TargetMetadata, base}; pub(crate) fn target() -> Target { let mut options = base::wasm::options(); @@ -47,7 +47,7 @@ pub(crate) fn target() -> Target { }, pointer_width: 64, data_layout: "e-m:e-p:64:64-p10:8:8-p20:8:8-i64:64-i128:128-n32:64-S128-ni:1:10:20".into(), - arch: "wasm64".into(), + arch: Arch::Wasm64, options, } } diff --git a/compiler/rustc_target/src/spec/targets/x86_64_fortanix_unknown_sgx.rs b/compiler/rustc_target/src/spec/targets/x86_64_fortanix_unknown_sgx.rs index bbaee6c1f6d9b..6232de48da707 100644 --- a/compiler/rustc_target/src/spec/targets/x86_64_fortanix_unknown_sgx.rs +++ b/compiler/rustc_target/src/spec/targets/x86_64_fortanix_unknown_sgx.rs @@ -1,6 +1,6 @@ use std::borrow::Cow; -use crate::spec::{Cc, LinkerFlavor, Lld, Target, TargetMetadata, TargetOptions, cvs}; +use crate::spec::{Arch, Cc, LinkerFlavor, Lld, Target, TargetMetadata, TargetOptions, cvs}; pub(crate) fn target() -> Target { let pre_link_args = TargetOptions::link_args( @@ -83,7 +83,7 @@ pub(crate) fn target() -> Target { pointer_width: 64, data_layout: "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128".into(), - arch: "x86_64".into(), + arch: Arch::X86_64, options: opts, } } diff --git a/compiler/rustc_target/src/spec/targets/x86_64_linux_android.rs b/compiler/rustc_target/src/spec/targets/x86_64_linux_android.rs index 3a0acaa028cbe..93d77b9d1dc34 100644 --- a/compiler/rustc_target/src/spec/targets/x86_64_linux_android.rs +++ b/compiler/rustc_target/src/spec/targets/x86_64_linux_android.rs @@ -1,6 +1,6 @@ use crate::spec::{ - Cc, LinkerFlavor, Lld, SanitizerSet, StackProbeType, Target, TargetMetadata, TargetOptions, - base, + Arch, Cc, LinkerFlavor, Lld, SanitizerSet, StackProbeType, Target, TargetMetadata, + TargetOptions, base, }; pub(crate) fn target() -> Target { @@ -25,7 +25,7 @@ pub(crate) fn target() -> Target { pointer_width: 64, data_layout: "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128".into(), - arch: "x86_64".into(), + arch: Arch::X86_64, options: TargetOptions { supported_sanitizers: SanitizerSet::ADDRESS, ..base }, } } diff --git a/compiler/rustc_target/src/spec/targets/x86_64_lynx_lynxos178.rs b/compiler/rustc_target/src/spec/targets/x86_64_lynx_lynxos178.rs index 654ae7c9c5bea..933e716236fa1 100644 --- a/compiler/rustc_target/src/spec/targets/x86_64_lynx_lynxos178.rs +++ b/compiler/rustc_target/src/spec/targets/x86_64_lynx_lynxos178.rs @@ -1,4 +1,4 @@ -use crate::spec::{SanitizerSet, StackProbeType, Target, base}; +use crate::spec::{Arch, SanitizerSet, StackProbeType, Target, base}; pub(crate) fn target() -> Target { let mut base = base::lynxos178::opts(); @@ -28,7 +28,7 @@ pub(crate) fn target() -> Target { pointer_width: 64, data_layout: "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128".into(), - arch: "x86_64".into(), + arch: Arch::X86_64, options: base, } } diff --git a/compiler/rustc_target/src/spec/targets/x86_64_pc_cygwin.rs b/compiler/rustc_target/src/spec/targets/x86_64_pc_cygwin.rs index eac4caf41c8bc..1d7ecc25a6332 100644 --- a/compiler/rustc_target/src/spec/targets/x86_64_pc_cygwin.rs +++ b/compiler/rustc_target/src/spec/targets/x86_64_pc_cygwin.rs @@ -1,4 +1,4 @@ -use crate::spec::{Cc, LinkerFlavor, Lld, Target, base}; +use crate::spec::{Arch, Cc, LinkerFlavor, Lld, Target, base}; pub(crate) fn target() -> Target { let mut base = base::cygwin::opts(); @@ -12,7 +12,7 @@ pub(crate) fn target() -> Target { pointer_width: 64, data_layout: "e-m:w-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128".into(), - arch: "x86_64".into(), + arch: Arch::X86_64, options: base, metadata: crate::spec::TargetMetadata { description: Some("64-bit x86 Cygwin".into()), diff --git a/compiler/rustc_target/src/spec/targets/x86_64_pc_solaris.rs b/compiler/rustc_target/src/spec/targets/x86_64_pc_solaris.rs index 662bbc4a31c4a..7b8d5def3a70b 100644 --- a/compiler/rustc_target/src/spec/targets/x86_64_pc_solaris.rs +++ b/compiler/rustc_target/src/spec/targets/x86_64_pc_solaris.rs @@ -1,4 +1,6 @@ -use crate::spec::{Cc, LinkerFlavor, SanitizerSet, StackProbeType, Target, TargetMetadata, base}; +use crate::spec::{ + Arch, Cc, LinkerFlavor, SanitizerSet, StackProbeType, Target, TargetMetadata, base, +}; pub(crate) fn target() -> Target { let mut base = base::solaris::opts(); @@ -21,7 +23,7 @@ pub(crate) fn target() -> Target { pointer_width: 64, data_layout: "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128".into(), - arch: "x86_64".into(), + arch: Arch::X86_64, options: base, } } diff --git a/compiler/rustc_target/src/spec/targets/x86_64_pc_windows_gnu.rs b/compiler/rustc_target/src/spec/targets/x86_64_pc_windows_gnu.rs index 16bdd3ee6684d..ba0882b8693b1 100644 --- a/compiler/rustc_target/src/spec/targets/x86_64_pc_windows_gnu.rs +++ b/compiler/rustc_target/src/spec/targets/x86_64_pc_windows_gnu.rs @@ -1,4 +1,4 @@ -use crate::spec::{Cc, LinkerFlavor, Lld, Target, TargetMetadata, base}; +use crate::spec::{Arch, Cc, LinkerFlavor, Lld, Target, TargetMetadata, base}; pub(crate) fn target() -> Target { let mut base = base::windows_gnu::opts(); @@ -25,7 +25,7 @@ pub(crate) fn target() -> Target { pointer_width: 64, data_layout: "e-m:w-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128".into(), - arch: "x86_64".into(), + arch: Arch::X86_64, options: base, } } diff --git a/compiler/rustc_target/src/spec/targets/x86_64_pc_windows_gnullvm.rs b/compiler/rustc_target/src/spec/targets/x86_64_pc_windows_gnullvm.rs index 1a03390c2b89a..28c9e6251255c 100644 --- a/compiler/rustc_target/src/spec/targets/x86_64_pc_windows_gnullvm.rs +++ b/compiler/rustc_target/src/spec/targets/x86_64_pc_windows_gnullvm.rs @@ -1,4 +1,4 @@ -use crate::spec::{Cc, LinkerFlavor, Lld, Target, TargetMetadata, base}; +use crate::spec::{Arch, Cc, LinkerFlavor, Lld, Target, TargetMetadata, base}; pub(crate) fn target() -> Target { let mut base = base::windows_gnullvm::opts(); @@ -20,7 +20,7 @@ pub(crate) fn target() -> Target { pointer_width: 64, data_layout: "e-m:w-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128".into(), - arch: "x86_64".into(), + arch: Arch::X86_64, options: base, } } diff --git a/compiler/rustc_target/src/spec/targets/x86_64_pc_windows_msvc.rs b/compiler/rustc_target/src/spec/targets/x86_64_pc_windows_msvc.rs index d88aabaa6d336..1eecec8e6bde7 100644 --- a/compiler/rustc_target/src/spec/targets/x86_64_pc_windows_msvc.rs +++ b/compiler/rustc_target/src/spec/targets/x86_64_pc_windows_msvc.rs @@ -1,4 +1,4 @@ -use crate::spec::{SanitizerSet, Target, TargetMetadata, base}; +use crate::spec::{Arch, SanitizerSet, Target, TargetMetadata, base}; pub(crate) fn target() -> Target { let mut base = base::windows_msvc::opts(); @@ -19,7 +19,7 @@ pub(crate) fn target() -> Target { pointer_width: 64, data_layout: "e-m:w-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128".into(), - arch: "x86_64".into(), + arch: Arch::X86_64, options: base, } } diff --git a/compiler/rustc_target/src/spec/targets/x86_64_unikraft_linux_musl.rs b/compiler/rustc_target/src/spec/targets/x86_64_unikraft_linux_musl.rs index f5bc3ab707db6..c5421f3e6b748 100644 --- a/compiler/rustc_target/src/spec/targets/x86_64_unikraft_linux_musl.rs +++ b/compiler/rustc_target/src/spec/targets/x86_64_unikraft_linux_musl.rs @@ -1,5 +1,5 @@ use crate::spec::{ - Cc, LinkerFlavor, Lld, StackProbeType, Target, TargetMetadata, TargetOptions, base, + Arch, Cc, LinkerFlavor, Lld, StackProbeType, Target, TargetMetadata, TargetOptions, base, }; pub(crate) fn target() -> Target { @@ -12,7 +12,7 @@ pub(crate) fn target() -> Target { std: Some(true), }, pointer_width: 64, - arch: "x86_64".into(), + arch: Arch::X86_64, data_layout: "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128".into(), options: TargetOptions { diff --git a/compiler/rustc_target/src/spec/targets/x86_64_unknown_dragonfly.rs b/compiler/rustc_target/src/spec/targets/x86_64_unknown_dragonfly.rs index 715c0db632b16..99f10ca7ec3f2 100644 --- a/compiler/rustc_target/src/spec/targets/x86_64_unknown_dragonfly.rs +++ b/compiler/rustc_target/src/spec/targets/x86_64_unknown_dragonfly.rs @@ -1,4 +1,4 @@ -use crate::spec::{Cc, LinkerFlavor, Lld, StackProbeType, Target, TargetMetadata, base}; +use crate::spec::{Arch, Cc, LinkerFlavor, Lld, StackProbeType, Target, TargetMetadata, base}; pub(crate) fn target() -> Target { let mut base = base::dragonfly::opts(); @@ -19,7 +19,7 @@ pub(crate) fn target() -> Target { pointer_width: 64, data_layout: "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128".into(), - arch: "x86_64".into(), + arch: Arch::X86_64, options: base, } } diff --git a/compiler/rustc_target/src/spec/targets/x86_64_unknown_freebsd.rs b/compiler/rustc_target/src/spec/targets/x86_64_unknown_freebsd.rs index 4a074539aab75..3043fd2a43bd6 100644 --- a/compiler/rustc_target/src/spec/targets/x86_64_unknown_freebsd.rs +++ b/compiler/rustc_target/src/spec/targets/x86_64_unknown_freebsd.rs @@ -1,5 +1,5 @@ use crate::spec::{ - Cc, LinkerFlavor, Lld, SanitizerSet, StackProbeType, Target, TargetMetadata, base, + Arch, Cc, LinkerFlavor, Lld, SanitizerSet, StackProbeType, Target, TargetMetadata, base, }; pub(crate) fn target() -> Target { @@ -24,7 +24,7 @@ pub(crate) fn target() -> Target { pointer_width: 64, data_layout: "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128".into(), - arch: "x86_64".into(), + arch: Arch::X86_64, options: base, } } diff --git a/compiler/rustc_target/src/spec/targets/x86_64_unknown_fuchsia.rs b/compiler/rustc_target/src/spec/targets/x86_64_unknown_fuchsia.rs index d7253da7e8d66..0d92097ad456e 100644 --- a/compiler/rustc_target/src/spec/targets/x86_64_unknown_fuchsia.rs +++ b/compiler/rustc_target/src/spec/targets/x86_64_unknown_fuchsia.rs @@ -1,4 +1,4 @@ -use crate::spec::{SanitizerSet, StackProbeType, Target, TargetMetadata, base}; +use crate::spec::{Arch, SanitizerSet, StackProbeType, Target, TargetMetadata, base}; pub(crate) fn target() -> Target { let mut base = base::fuchsia::opts(); @@ -23,7 +23,7 @@ pub(crate) fn target() -> Target { pointer_width: 64, data_layout: "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128".into(), - arch: "x86_64".into(), + arch: Arch::X86_64, options: base, } } diff --git a/compiler/rustc_target/src/spec/targets/x86_64_unknown_haiku.rs b/compiler/rustc_target/src/spec/targets/x86_64_unknown_haiku.rs index ecb9fc80351e1..85659373421f7 100644 --- a/compiler/rustc_target/src/spec/targets/x86_64_unknown_haiku.rs +++ b/compiler/rustc_target/src/spec/targets/x86_64_unknown_haiku.rs @@ -1,4 +1,4 @@ -use crate::spec::{Cc, LinkerFlavor, Lld, StackProbeType, Target, TargetMetadata, base}; +use crate::spec::{Arch, Cc, LinkerFlavor, Lld, StackProbeType, Target, TargetMetadata, base}; pub(crate) fn target() -> Target { let mut base = base::haiku::opts(); @@ -21,7 +21,7 @@ pub(crate) fn target() -> Target { pointer_width: 64, data_layout: "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128".into(), - arch: "x86_64".into(), + arch: Arch::X86_64, options: base, } } diff --git a/compiler/rustc_target/src/spec/targets/x86_64_unknown_helenos.rs b/compiler/rustc_target/src/spec/targets/x86_64_unknown_helenos.rs index 82c9807f73e3e..42e46fa4ef9d1 100644 --- a/compiler/rustc_target/src/spec/targets/x86_64_unknown_helenos.rs +++ b/compiler/rustc_target/src/spec/targets/x86_64_unknown_helenos.rs @@ -1,4 +1,4 @@ -use crate::spec::{Cc, LinkerFlavor, Lld, Target, base}; +use crate::spec::{Arch, Cc, LinkerFlavor, Lld, Target, base}; pub(crate) fn target() -> Target { let mut base = base::helenos::opts(); @@ -19,7 +19,7 @@ pub(crate) fn target() -> Target { pointer_width: 64, data_layout: "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128".into(), - arch: "x86_64".into(), + arch: Arch::X86_64, options: base, } } diff --git a/compiler/rustc_target/src/spec/targets/x86_64_unknown_hermit.rs b/compiler/rustc_target/src/spec/targets/x86_64_unknown_hermit.rs index 7abde77179816..ee191ac95ae71 100644 --- a/compiler/rustc_target/src/spec/targets/x86_64_unknown_hermit.rs +++ b/compiler/rustc_target/src/spec/targets/x86_64_unknown_hermit.rs @@ -1,4 +1,4 @@ -use crate::spec::{StackProbeType, Target, TargetMetadata, TargetOptions, base}; +use crate::spec::{Arch, StackProbeType, Target, TargetMetadata, TargetOptions, base}; pub(crate) fn target() -> Target { Target { @@ -10,7 +10,7 @@ pub(crate) fn target() -> Target { std: Some(true), }, pointer_width: 64, - arch: "x86_64".into(), + arch: Arch::X86_64, data_layout: "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128".into(), options: TargetOptions { diff --git a/compiler/rustc_target/src/spec/targets/x86_64_unknown_hurd_gnu.rs b/compiler/rustc_target/src/spec/targets/x86_64_unknown_hurd_gnu.rs index 57ce67af36d68..cf282335b966b 100644 --- a/compiler/rustc_target/src/spec/targets/x86_64_unknown_hurd_gnu.rs +++ b/compiler/rustc_target/src/spec/targets/x86_64_unknown_hurd_gnu.rs @@ -1,4 +1,4 @@ -use crate::spec::{Cc, LinkerFlavor, Lld, StackProbeType, Target, TargetMetadata, base}; +use crate::spec::{Arch, Cc, LinkerFlavor, Lld, StackProbeType, Target, TargetMetadata, base}; pub(crate) fn target() -> Target { let mut base = base::hurd_gnu::opts(); @@ -20,7 +20,7 @@ pub(crate) fn target() -> Target { pointer_width: 64, data_layout: "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128".into(), - arch: "x86_64".into(), + arch: Arch::X86_64, options: base, } } diff --git a/compiler/rustc_target/src/spec/targets/x86_64_unknown_illumos.rs b/compiler/rustc_target/src/spec/targets/x86_64_unknown_illumos.rs index 17f90db0c9066..9510ed5791dd9 100644 --- a/compiler/rustc_target/src/spec/targets/x86_64_unknown_illumos.rs +++ b/compiler/rustc_target/src/spec/targets/x86_64_unknown_illumos.rs @@ -1,4 +1,4 @@ -use crate::spec::{Cc, LinkerFlavor, SanitizerSet, Target, TargetMetadata, base}; +use crate::spec::{Arch, Cc, LinkerFlavor, SanitizerSet, Target, TargetMetadata, base}; pub(crate) fn target() -> Target { let mut base = base::illumos::opts(); @@ -21,7 +21,7 @@ pub(crate) fn target() -> Target { pointer_width: 64, data_layout: "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128".into(), - arch: "x86_64".into(), + arch: Arch::X86_64, options: base, } } diff --git a/compiler/rustc_target/src/spec/targets/x86_64_unknown_l4re_uclibc.rs b/compiler/rustc_target/src/spec/targets/x86_64_unknown_l4re_uclibc.rs index 4107249dcf1e3..5ab6b094dfa06 100644 --- a/compiler/rustc_target/src/spec/targets/x86_64_unknown_l4re_uclibc.rs +++ b/compiler/rustc_target/src/spec/targets/x86_64_unknown_l4re_uclibc.rs @@ -1,4 +1,4 @@ -use crate::spec::{PanicStrategy, Target, TargetMetadata, base}; +use crate::spec::{Arch, PanicStrategy, Target, TargetMetadata, base}; pub(crate) fn target() -> Target { let mut base = base::l4re::opts(); @@ -18,7 +18,7 @@ pub(crate) fn target() -> Target { pointer_width: 64, data_layout: "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128".into(), - arch: "x86_64".into(), + arch: Arch::X86_64, options: base, } } diff --git a/compiler/rustc_target/src/spec/targets/x86_64_unknown_linux_gnu.rs b/compiler/rustc_target/src/spec/targets/x86_64_unknown_linux_gnu.rs index 59bb7f5962101..adb7a43a62320 100644 --- a/compiler/rustc_target/src/spec/targets/x86_64_unknown_linux_gnu.rs +++ b/compiler/rustc_target/src/spec/targets/x86_64_unknown_linux_gnu.rs @@ -1,5 +1,5 @@ use crate::spec::{ - Cc, LinkerFlavor, Lld, SanitizerSet, StackProbeType, Target, TargetMetadata, base, + Arch, Cc, LinkerFlavor, Lld, SanitizerSet, StackProbeType, Target, TargetMetadata, base, }; pub(crate) fn target() -> Target { @@ -31,7 +31,7 @@ pub(crate) fn target() -> Target { pointer_width: 64, data_layout: "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128".into(), - arch: "x86_64".into(), + arch: Arch::X86_64, options: base, } } diff --git a/compiler/rustc_target/src/spec/targets/x86_64_unknown_linux_gnux32.rs b/compiler/rustc_target/src/spec/targets/x86_64_unknown_linux_gnux32.rs index c5d556e5cc650..0b3e25bebf361 100644 --- a/compiler/rustc_target/src/spec/targets/x86_64_unknown_linux_gnux32.rs +++ b/compiler/rustc_target/src/spec/targets/x86_64_unknown_linux_gnux32.rs @@ -1,4 +1,4 @@ -use crate::spec::{Cc, LinkerFlavor, Lld, StackProbeType, Target, TargetMetadata, base}; +use crate::spec::{Arch, Cc, LinkerFlavor, Lld, StackProbeType, Target, TargetMetadata, base}; pub(crate) fn target() -> Target { let mut base = base::linux_gnu::opts(); @@ -24,7 +24,7 @@ pub(crate) fn target() -> Target { data_layout: "e-m:e-p:32:32-p270:32:32-p271:32:32-p272:64:64-\ i64:64-i128:128-f80:128-n8:16:32:64-S128" .into(), - arch: "x86_64".into(), + arch: Arch::X86_64, options: base, } } diff --git a/compiler/rustc_target/src/spec/targets/x86_64_unknown_linux_musl.rs b/compiler/rustc_target/src/spec/targets/x86_64_unknown_linux_musl.rs index 3cb2a962a5624..ee883532ad4ac 100644 --- a/compiler/rustc_target/src/spec/targets/x86_64_unknown_linux_musl.rs +++ b/compiler/rustc_target/src/spec/targets/x86_64_unknown_linux_musl.rs @@ -1,5 +1,5 @@ use crate::spec::{ - Cc, LinkerFlavor, Lld, SanitizerSet, StackProbeType, Target, TargetMetadata, base, + Arch, Cc, LinkerFlavor, Lld, SanitizerSet, StackProbeType, Target, TargetMetadata, base, }; pub(crate) fn target() -> Target { @@ -30,7 +30,7 @@ pub(crate) fn target() -> Target { pointer_width: 64, data_layout: "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128".into(), - arch: "x86_64".into(), + arch: Arch::X86_64, options: base, } } diff --git a/compiler/rustc_target/src/spec/targets/x86_64_unknown_linux_none.rs b/compiler/rustc_target/src/spec/targets/x86_64_unknown_linux_none.rs index 896e8a78f863a..ecf232f1ab2fa 100644 --- a/compiler/rustc_target/src/spec/targets/x86_64_unknown_linux_none.rs +++ b/compiler/rustc_target/src/spec/targets/x86_64_unknown_linux_none.rs @@ -1,5 +1,5 @@ use crate::spec::{ - Cc, LinkerFlavor, Lld, PanicStrategy, StackProbeType, Target, TargetMetadata, base, + Arch, Cc, LinkerFlavor, Lld, PanicStrategy, StackProbeType, Target, TargetMetadata, base, }; pub(crate) fn target() -> Target { @@ -22,7 +22,7 @@ pub(crate) fn target() -> Target { pointer_width: 64, data_layout: "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128".into(), - arch: "x86_64".into(), + arch: Arch::X86_64, options: base, } } diff --git a/compiler/rustc_target/src/spec/targets/x86_64_unknown_linux_ohos.rs b/compiler/rustc_target/src/spec/targets/x86_64_unknown_linux_ohos.rs index de9027ba9622b..c6c55c148f64c 100644 --- a/compiler/rustc_target/src/spec/targets/x86_64_unknown_linux_ohos.rs +++ b/compiler/rustc_target/src/spec/targets/x86_64_unknown_linux_ohos.rs @@ -1,5 +1,5 @@ use crate::spec::{ - Cc, LinkerFlavor, Lld, SanitizerSet, StackProbeType, Target, TargetMetadata, base, + Arch, Cc, LinkerFlavor, Lld, SanitizerSet, StackProbeType, Target, TargetMetadata, base, }; pub(crate) fn target() -> Target { @@ -27,7 +27,7 @@ pub(crate) fn target() -> Target { pointer_width: 64, data_layout: "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128".into(), - arch: "x86_64".into(), + arch: Arch::X86_64, options: base, } } diff --git a/compiler/rustc_target/src/spec/targets/x86_64_unknown_managarm_mlibc.rs b/compiler/rustc_target/src/spec/targets/x86_64_unknown_managarm_mlibc.rs index 359e38cb80079..98997c98749c2 100644 --- a/compiler/rustc_target/src/spec/targets/x86_64_unknown_managarm_mlibc.rs +++ b/compiler/rustc_target/src/spec/targets/x86_64_unknown_managarm_mlibc.rs @@ -1,4 +1,4 @@ -use crate::spec::{Cc, LinkerFlavor, Lld, StackProbeType, Target, base}; +use crate::spec::{Arch, Cc, LinkerFlavor, Lld, StackProbeType, Target, base}; pub(crate) fn target() -> Target { let mut base = base::managarm_mlibc::opts(); @@ -18,7 +18,7 @@ pub(crate) fn target() -> Target { pointer_width: 64, data_layout: "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128".into(), - arch: "x86_64".into(), + arch: Arch::X86_64, options: base, } } diff --git a/compiler/rustc_target/src/spec/targets/x86_64_unknown_motor.rs b/compiler/rustc_target/src/spec/targets/x86_64_unknown_motor.rs index 0fd43357a7664..3be05b79954f2 100644 --- a/compiler/rustc_target/src/spec/targets/x86_64_unknown_motor.rs +++ b/compiler/rustc_target/src/spec/targets/x86_64_unknown_motor.rs @@ -1,5 +1,5 @@ use crate::spec::{ - CodeModel, LinkSelfContainedDefault, LldFlavor, RelocModel, RelroLevel, Target, base, + Arch, CodeModel, LinkSelfContainedDefault, LldFlavor, RelocModel, RelroLevel, Target, base, }; pub(crate) fn target() -> Target { @@ -32,7 +32,7 @@ pub(crate) fn target() -> Target { pointer_width: 64, data_layout: "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128".into(), - arch: "x86_64".into(), + arch: Arch::X86_64, options: base, } } diff --git a/compiler/rustc_target/src/spec/targets/x86_64_unknown_netbsd.rs b/compiler/rustc_target/src/spec/targets/x86_64_unknown_netbsd.rs index 0403c220982dc..2561fe48bcc89 100644 --- a/compiler/rustc_target/src/spec/targets/x86_64_unknown_netbsd.rs +++ b/compiler/rustc_target/src/spec/targets/x86_64_unknown_netbsd.rs @@ -1,6 +1,6 @@ use crate::spec::{ - Cc, LinkerFlavor, Lld, SanitizerSet, StackProbeType, Target, TargetMetadata, TargetOptions, - base, + Arch, Cc, LinkerFlavor, Lld, SanitizerSet, StackProbeType, Target, TargetMetadata, + TargetOptions, base, }; pub(crate) fn target() -> Target { @@ -28,7 +28,7 @@ pub(crate) fn target() -> Target { pointer_width: 64, data_layout: "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128".into(), - arch: "x86_64".into(), + arch: Arch::X86_64, options: TargetOptions { mcount: "__mcount".into(), ..base }, } } diff --git a/compiler/rustc_target/src/spec/targets/x86_64_unknown_none.rs b/compiler/rustc_target/src/spec/targets/x86_64_unknown_none.rs index 1a6343595f545..520a59d6a6f6c 100644 --- a/compiler/rustc_target/src/spec/targets/x86_64_unknown_none.rs +++ b/compiler/rustc_target/src/spec/targets/x86_64_unknown_none.rs @@ -5,7 +5,7 @@ // features. use crate::spec::{ - Cc, CodeModel, LinkerFlavor, Lld, PanicStrategy, RelroLevel, RustcAbi, SanitizerSet, + Arch, Cc, CodeModel, LinkerFlavor, Lld, PanicStrategy, RelroLevel, RustcAbi, SanitizerSet, StackProbeType, Target, TargetMetadata, TargetOptions, }; @@ -39,7 +39,7 @@ pub(crate) fn target() -> Target { pointer_width: 64, data_layout: "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128".into(), - arch: "x86_64".into(), + arch: Arch::X86_64, options: opts, } } diff --git a/compiler/rustc_target/src/spec/targets/x86_64_unknown_openbsd.rs b/compiler/rustc_target/src/spec/targets/x86_64_unknown_openbsd.rs index 2eb09b8cbada6..c911de4aee823 100644 --- a/compiler/rustc_target/src/spec/targets/x86_64_unknown_openbsd.rs +++ b/compiler/rustc_target/src/spec/targets/x86_64_unknown_openbsd.rs @@ -1,4 +1,4 @@ -use crate::spec::{Cc, LinkerFlavor, Lld, StackProbeType, Target, TargetMetadata, base}; +use crate::spec::{Arch, Cc, LinkerFlavor, Lld, StackProbeType, Target, TargetMetadata, base}; pub(crate) fn target() -> Target { let mut base = base::openbsd::opts(); @@ -20,7 +20,7 @@ pub(crate) fn target() -> Target { pointer_width: 64, data_layout: "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128".into(), - arch: "x86_64".into(), + arch: Arch::X86_64, options: base, } } diff --git a/compiler/rustc_target/src/spec/targets/x86_64_unknown_redox.rs b/compiler/rustc_target/src/spec/targets/x86_64_unknown_redox.rs index 65b8e2543a410..562beab760b70 100644 --- a/compiler/rustc_target/src/spec/targets/x86_64_unknown_redox.rs +++ b/compiler/rustc_target/src/spec/targets/x86_64_unknown_redox.rs @@ -1,4 +1,4 @@ -use crate::spec::{Cc, LinkerFlavor, Lld, StackProbeType, Target, TargetMetadata, base}; +use crate::spec::{Arch, Cc, LinkerFlavor, Lld, StackProbeType, Target, TargetMetadata, base}; pub(crate) fn target() -> Target { let mut base = base::redox::opts(); @@ -19,7 +19,7 @@ pub(crate) fn target() -> Target { pointer_width: 64, data_layout: "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128".into(), - arch: "x86_64".into(), + arch: Arch::X86_64, options: base, } } diff --git a/compiler/rustc_target/src/spec/targets/x86_64_unknown_trusty.rs b/compiler/rustc_target/src/spec/targets/x86_64_unknown_trusty.rs index dbcb5fd4e11e2..88c66ff6db9f1 100644 --- a/compiler/rustc_target/src/spec/targets/x86_64_unknown_trusty.rs +++ b/compiler/rustc_target/src/spec/targets/x86_64_unknown_trusty.rs @@ -1,8 +1,8 @@ // Trusty OS target for X86_64. use crate::spec::{ - LinkSelfContainedDefault, PanicStrategy, RelroLevel, StackProbeType, Target, TargetMetadata, - TargetOptions, + Arch, LinkSelfContainedDefault, PanicStrategy, RelroLevel, StackProbeType, Target, + TargetMetadata, TargetOptions, }; pub(crate) fn target() -> Target { @@ -17,7 +17,7 @@ pub(crate) fn target() -> Target { pointer_width: 64, data_layout: "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128".into(), - arch: "x86_64".into(), + arch: Arch::X86_64, options: TargetOptions { executables: true, max_atomic_width: Some(64), diff --git a/compiler/rustc_target/src/spec/targets/x86_64_unknown_uefi.rs b/compiler/rustc_target/src/spec/targets/x86_64_unknown_uefi.rs index 0cf6a87946219..8a494d0e56dd3 100644 --- a/compiler/rustc_target/src/spec/targets/x86_64_unknown_uefi.rs +++ b/compiler/rustc_target/src/spec/targets/x86_64_unknown_uefi.rs @@ -7,7 +7,7 @@ use rustc_abi::{CanonAbi, X86Call}; -use crate::spec::{RustcAbi, Target, TargetMetadata, base}; +use crate::spec::{Arch, RustcAbi, Target, TargetMetadata, base}; pub(crate) fn target() -> Target { let mut base = base::uefi_msvc::opts(); @@ -40,7 +40,7 @@ pub(crate) fn target() -> Target { pointer_width: 64, data_layout: "e-m:w-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128".into(), - arch: "x86_64".into(), + arch: Arch::X86_64, options: base, } diff --git a/compiler/rustc_target/src/spec/targets/x86_64_uwp_windows_gnu.rs b/compiler/rustc_target/src/spec/targets/x86_64_uwp_windows_gnu.rs index bf6179cb6c384..96d1bd2764c8e 100644 --- a/compiler/rustc_target/src/spec/targets/x86_64_uwp_windows_gnu.rs +++ b/compiler/rustc_target/src/spec/targets/x86_64_uwp_windows_gnu.rs @@ -1,4 +1,4 @@ -use crate::spec::{Cc, LinkerFlavor, Lld, Target, TargetMetadata, base}; +use crate::spec::{Arch, Cc, LinkerFlavor, Lld, Target, TargetMetadata, base}; pub(crate) fn target() -> Target { let mut base = base::windows_uwp_gnu::opts(); @@ -24,7 +24,7 @@ pub(crate) fn target() -> Target { pointer_width: 64, data_layout: "e-m:w-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128".into(), - arch: "x86_64".into(), + arch: Arch::X86_64, options: base, } } diff --git a/compiler/rustc_target/src/spec/targets/x86_64_uwp_windows_msvc.rs b/compiler/rustc_target/src/spec/targets/x86_64_uwp_windows_msvc.rs index 50b0578da3572..3be6abd3d9757 100644 --- a/compiler/rustc_target/src/spec/targets/x86_64_uwp_windows_msvc.rs +++ b/compiler/rustc_target/src/spec/targets/x86_64_uwp_windows_msvc.rs @@ -1,4 +1,4 @@ -use crate::spec::{Target, TargetMetadata, base}; +use crate::spec::{Arch, Target, TargetMetadata, base}; pub(crate) fn target() -> Target { let mut base = base::windows_uwp_msvc::opts(); @@ -18,7 +18,7 @@ pub(crate) fn target() -> Target { pointer_width: 64, data_layout: "e-m:w-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128".into(), - arch: "x86_64".into(), + arch: Arch::X86_64, options: base, } } diff --git a/compiler/rustc_target/src/spec/targets/x86_64_win7_windows_gnu.rs b/compiler/rustc_target/src/spec/targets/x86_64_win7_windows_gnu.rs index df1fe8e7853cc..22a1a126b8912 100644 --- a/compiler/rustc_target/src/spec/targets/x86_64_win7_windows_gnu.rs +++ b/compiler/rustc_target/src/spec/targets/x86_64_win7_windows_gnu.rs @@ -1,4 +1,4 @@ -use crate::spec::{Cc, LinkerFlavor, Lld, Target, TargetMetadata, base}; +use crate::spec::{Arch, Cc, LinkerFlavor, Lld, Target, TargetMetadata, base}; pub(crate) fn target() -> Target { let mut base = base::windows_gnu::opts(); @@ -25,7 +25,7 @@ pub(crate) fn target() -> Target { pointer_width: 64, data_layout: "e-m:w-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128".into(), - arch: "x86_64".into(), + arch: Arch::X86_64, options: base, } } diff --git a/compiler/rustc_target/src/spec/targets/x86_64_win7_windows_msvc.rs b/compiler/rustc_target/src/spec/targets/x86_64_win7_windows_msvc.rs index 876ac01187923..99b59154811f2 100644 --- a/compiler/rustc_target/src/spec/targets/x86_64_win7_windows_msvc.rs +++ b/compiler/rustc_target/src/spec/targets/x86_64_win7_windows_msvc.rs @@ -1,4 +1,4 @@ -use crate::spec::{SanitizerSet, Target, TargetMetadata, base}; +use crate::spec::{Arch, SanitizerSet, Target, TargetMetadata, base}; pub(crate) fn target() -> Target { let mut base = base::windows_msvc::opts(); @@ -19,7 +19,7 @@ pub(crate) fn target() -> Target { pointer_width: 64, data_layout: "e-m:w-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128".into(), - arch: "x86_64".into(), + arch: Arch::X86_64, options: base, } } diff --git a/compiler/rustc_target/src/spec/targets/x86_64_wrs_vxworks.rs b/compiler/rustc_target/src/spec/targets/x86_64_wrs_vxworks.rs index 9ab62b3530fab..0bc3749714604 100644 --- a/compiler/rustc_target/src/spec/targets/x86_64_wrs_vxworks.rs +++ b/compiler/rustc_target/src/spec/targets/x86_64_wrs_vxworks.rs @@ -1,4 +1,4 @@ -use crate::spec::{Cc, LinkerFlavor, Lld, StackProbeType, Target, TargetMetadata, base}; +use crate::spec::{Arch, Cc, LinkerFlavor, Lld, StackProbeType, Target, TargetMetadata, base}; pub(crate) fn target() -> Target { let mut base = base::vxworks::opts(); @@ -20,7 +20,7 @@ pub(crate) fn target() -> Target { pointer_width: 64, data_layout: "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128".into(), - arch: "x86_64".into(), + arch: Arch::X86_64, options: base, } } diff --git a/compiler/rustc_target/src/spec/targets/xtensa_esp32_espidf.rs b/compiler/rustc_target/src/spec/targets/xtensa_esp32_espidf.rs index 8a6773811e882..d909271e218e0 100644 --- a/compiler/rustc_target/src/spec/targets/xtensa_esp32_espidf.rs +++ b/compiler/rustc_target/src/spec/targets/xtensa_esp32_espidf.rs @@ -1,14 +1,14 @@ use rustc_abi::Endian; use crate::spec::base::xtensa; -use crate::spec::{Target, TargetMetadata, TargetOptions, cvs}; +use crate::spec::{Arch, Target, TargetMetadata, TargetOptions, cvs}; pub(crate) fn target() -> Target { Target { llvm_target: "xtensa-none-elf".into(), pointer_width: 32, data_layout: "e-m:e-p:32:32-v1:8:8-i64:64-i128:128-n32".into(), - arch: "xtensa".into(), + arch: Arch::Xtensa, metadata: TargetMetadata { description: None, tier: None, host_tools: None, std: None }, options: TargetOptions { diff --git a/compiler/rustc_target/src/spec/targets/xtensa_esp32_none_elf.rs b/compiler/rustc_target/src/spec/targets/xtensa_esp32_none_elf.rs index d8638e8ac8050..82c6e0cfa3f62 100644 --- a/compiler/rustc_target/src/spec/targets/xtensa_esp32_none_elf.rs +++ b/compiler/rustc_target/src/spec/targets/xtensa_esp32_none_elf.rs @@ -1,12 +1,12 @@ use crate::spec::base::xtensa; -use crate::spec::{Target, TargetMetadata, TargetOptions}; +use crate::spec::{Arch, Target, TargetMetadata, TargetOptions}; pub(crate) fn target() -> Target { Target { llvm_target: "xtensa-none-elf".into(), pointer_width: 32, data_layout: "e-m:e-p:32:32-v1:8:8-i64:64-i128:128-n32".into(), - arch: "xtensa".into(), + arch: Arch::Xtensa, metadata: TargetMetadata { description: Some("Xtensa ESP32".into()), tier: Some(3), diff --git a/compiler/rustc_target/src/spec/targets/xtensa_esp32s2_espidf.rs b/compiler/rustc_target/src/spec/targets/xtensa_esp32s2_espidf.rs index f38d771f2579a..b1ed0ffe264e3 100644 --- a/compiler/rustc_target/src/spec/targets/xtensa_esp32s2_espidf.rs +++ b/compiler/rustc_target/src/spec/targets/xtensa_esp32s2_espidf.rs @@ -1,14 +1,14 @@ use rustc_abi::Endian; use crate::spec::base::xtensa; -use crate::spec::{Target, TargetMetadata, TargetOptions, cvs}; +use crate::spec::{Arch, Target, TargetMetadata, TargetOptions, cvs}; pub(crate) fn target() -> Target { Target { llvm_target: "xtensa-none-elf".into(), pointer_width: 32, data_layout: "e-m:e-p:32:32-v1:8:8-i64:64-i128:128-n32".into(), - arch: "xtensa".into(), + arch: Arch::Xtensa, metadata: TargetMetadata { description: None, tier: None, host_tools: None, std: None }, options: TargetOptions { diff --git a/compiler/rustc_target/src/spec/targets/xtensa_esp32s2_none_elf.rs b/compiler/rustc_target/src/spec/targets/xtensa_esp32s2_none_elf.rs index 7bf5834ab0aa0..755f4db3b2ddf 100644 --- a/compiler/rustc_target/src/spec/targets/xtensa_esp32s2_none_elf.rs +++ b/compiler/rustc_target/src/spec/targets/xtensa_esp32s2_none_elf.rs @@ -1,12 +1,12 @@ use crate::spec::base::xtensa; -use crate::spec::{Target, TargetMetadata, TargetOptions}; +use crate::spec::{Arch, Target, TargetMetadata, TargetOptions}; pub(crate) fn target() -> Target { Target { llvm_target: "xtensa-none-elf".into(), pointer_width: 32, data_layout: "e-m:e-p:32:32-v1:8:8-i64:64-i128:128-n32".into(), - arch: "xtensa".into(), + arch: Arch::Xtensa, metadata: TargetMetadata { description: Some("Xtensa ESP32-S2".into()), tier: Some(3), diff --git a/compiler/rustc_target/src/spec/targets/xtensa_esp32s3_espidf.rs b/compiler/rustc_target/src/spec/targets/xtensa_esp32s3_espidf.rs index 4ec6e319fd4f2..8e1fee4ad657a 100644 --- a/compiler/rustc_target/src/spec/targets/xtensa_esp32s3_espidf.rs +++ b/compiler/rustc_target/src/spec/targets/xtensa_esp32s3_espidf.rs @@ -1,14 +1,14 @@ use rustc_abi::Endian; use crate::spec::base::xtensa; -use crate::spec::{Target, TargetMetadata, TargetOptions, cvs}; +use crate::spec::{Arch, Target, TargetMetadata, TargetOptions, cvs}; pub(crate) fn target() -> Target { Target { llvm_target: "xtensa-none-elf".into(), pointer_width: 32, data_layout: "e-m:e-p:32:32-v1:8:8-i64:64-i128:128-n32".into(), - arch: "xtensa".into(), + arch: Arch::Xtensa, metadata: TargetMetadata { description: None, tier: None, host_tools: None, std: None }, options: TargetOptions { diff --git a/compiler/rustc_target/src/spec/targets/xtensa_esp32s3_none_elf.rs b/compiler/rustc_target/src/spec/targets/xtensa_esp32s3_none_elf.rs index d506888d8ee04..07530d874c09a 100644 --- a/compiler/rustc_target/src/spec/targets/xtensa_esp32s3_none_elf.rs +++ b/compiler/rustc_target/src/spec/targets/xtensa_esp32s3_none_elf.rs @@ -1,12 +1,12 @@ use crate::spec::base::xtensa; -use crate::spec::{Target, TargetMetadata, TargetOptions}; +use crate::spec::{Arch, Target, TargetMetadata, TargetOptions}; pub(crate) fn target() -> Target { Target { llvm_target: "xtensa-none-elf".into(), pointer_width: 32, data_layout: "e-m:e-p:32:32-v1:8:8-i64:64-i128:128-n32".into(), - arch: "xtensa".into(), + arch: Arch::Xtensa, metadata: TargetMetadata { description: Some("Xtensa ESP32-S3".into()), tier: Some(3), diff --git a/compiler/rustc_target/src/target_features.rs b/compiler/rustc_target/src/target_features.rs index 288ee6357a510..16c3558d535b3 100644 --- a/compiler/rustc_target/src/target_features.rs +++ b/compiler/rustc_target/src/target_features.rs @@ -5,7 +5,7 @@ use rustc_data_structures::fx::{FxHashMap, FxHashSet}; use rustc_data_structures::stable_hasher::{HashStable, StableHasher}; use rustc_span::{Symbol, sym}; -use crate::spec::{FloatAbi, RustcAbi, Target}; +use crate::spec::{Arch, FloatAbi, RustcAbi, Target}; /// Features that control behaviour of rustc, rather than the codegen. /// These exist globally and are not in the target-specific lists below. @@ -955,50 +955,62 @@ pub struct FeatureConstraints { impl Target { pub fn rust_target_features(&self) -> &'static [(&'static str, Stability, ImpliedFeatures)] { - match &*self.arch { - "arm" => ARM_FEATURES, - "aarch64" | "arm64ec" => AARCH64_FEATURES, - "x86" | "x86_64" => X86_FEATURES, - "hexagon" => HEXAGON_FEATURES, - "mips" | "mips32r6" | "mips64" | "mips64r6" => MIPS_FEATURES, - "nvptx64" => NVPTX_FEATURES, - "powerpc" | "powerpc64" => POWERPC_FEATURES, - "riscv32" | "riscv64" => RISCV_FEATURES, - "wasm32" | "wasm64" => WASM_FEATURES, - "bpf" => BPF_FEATURES, - "csky" => CSKY_FEATURES, - "loongarch32" | "loongarch64" => LOONGARCH_FEATURES, - "s390x" => IBMZ_FEATURES, - "sparc" | "sparc64" => SPARC_FEATURES, - "m68k" => M68K_FEATURES, - _ => &[], + match self.arch { + Arch::Arm => ARM_FEATURES, + Arch::AArch64 | Arch::Arm64EC => AARCH64_FEATURES, + Arch::X86 | Arch::X86_64 => X86_FEATURES, + Arch::Hexagon => HEXAGON_FEATURES, + Arch::Mips | Arch::Mips32r6 | Arch::Mips64 | Arch::Mips64r6 => MIPS_FEATURES, + Arch::Nvptx64 => NVPTX_FEATURES, + Arch::PowerPC | Arch::PowerPC64 => POWERPC_FEATURES, + Arch::RiscV32 | Arch::RiscV64 => RISCV_FEATURES, + Arch::Wasm32 | Arch::Wasm64 => WASM_FEATURES, + Arch::Bpf => BPF_FEATURES, + Arch::CSky => CSKY_FEATURES, + Arch::LoongArch32 | Arch::LoongArch64 => LOONGARCH_FEATURES, + Arch::S390x => IBMZ_FEATURES, + Arch::Sparc | Arch::Sparc64 => SPARC_FEATURES, + Arch::M68k => M68K_FEATURES, + Arch::AmdGpu + | Arch::Avr + | Arch::Msp430 + | Arch::PowerPC64LE + | Arch::SpirV + | Arch::Xtensa => &[], } } pub fn features_for_correct_vector_abi(&self) -> &'static [(u64, &'static str)] { - match &*self.arch { - "x86" | "x86_64" => X86_FEATURES_FOR_CORRECT_VECTOR_ABI, - "aarch64" | "arm64ec" => AARCH64_FEATURES_FOR_CORRECT_VECTOR_ABI, - "arm" => ARM_FEATURES_FOR_CORRECT_VECTOR_ABI, - "powerpc" | "powerpc64" => POWERPC_FEATURES_FOR_CORRECT_VECTOR_ABI, - "loongarch32" | "loongarch64" => LOONGARCH_FEATURES_FOR_CORRECT_VECTOR_ABI, - "riscv32" | "riscv64" => RISCV_FEATURES_FOR_CORRECT_VECTOR_ABI, - "wasm32" | "wasm64" => WASM_FEATURES_FOR_CORRECT_VECTOR_ABI, - "s390x" => S390X_FEATURES_FOR_CORRECT_VECTOR_ABI, - "sparc" | "sparc64" => SPARC_FEATURES_FOR_CORRECT_VECTOR_ABI, - "hexagon" => HEXAGON_FEATURES_FOR_CORRECT_VECTOR_ABI, - "mips" | "mips32r6" | "mips64" | "mips64r6" => MIPS_FEATURES_FOR_CORRECT_VECTOR_ABI, - "nvptx64" | "bpf" | "m68k" => &[], // no vector ABI - "csky" => CSKY_FEATURES_FOR_CORRECT_VECTOR_ABI, + match self.arch { + Arch::X86 | Arch::X86_64 => X86_FEATURES_FOR_CORRECT_VECTOR_ABI, + Arch::AArch64 | Arch::Arm64EC => AARCH64_FEATURES_FOR_CORRECT_VECTOR_ABI, + Arch::Arm => ARM_FEATURES_FOR_CORRECT_VECTOR_ABI, + Arch::PowerPC | Arch::PowerPC64 => POWERPC_FEATURES_FOR_CORRECT_VECTOR_ABI, + Arch::LoongArch32 | Arch::LoongArch64 => LOONGARCH_FEATURES_FOR_CORRECT_VECTOR_ABI, + Arch::RiscV32 | Arch::RiscV64 => RISCV_FEATURES_FOR_CORRECT_VECTOR_ABI, + Arch::Wasm32 | Arch::Wasm64 => WASM_FEATURES_FOR_CORRECT_VECTOR_ABI, + Arch::S390x => S390X_FEATURES_FOR_CORRECT_VECTOR_ABI, + Arch::Sparc | Arch::Sparc64 => SPARC_FEATURES_FOR_CORRECT_VECTOR_ABI, + Arch::Hexagon => HEXAGON_FEATURES_FOR_CORRECT_VECTOR_ABI, + Arch::Mips | Arch::Mips32r6 | Arch::Mips64 | Arch::Mips64r6 => { + MIPS_FEATURES_FOR_CORRECT_VECTOR_ABI + } + Arch::Nvptx64 | Arch::Bpf | Arch::M68k => &[], // no vector ABI + Arch::CSky => CSKY_FEATURES_FOR_CORRECT_VECTOR_ABI, // FIXME: for some tier3 targets, we are overly cautious and always give warnings // when passing args in vector registers. - _ => &[], + Arch::AmdGpu + | Arch::Avr + | Arch::Msp430 + | Arch::PowerPC64LE + | Arch::SpirV + | Arch::Xtensa => &[], } } pub fn tied_target_features(&self) -> &'static [&'static [&'static str]] { - match &*self.arch { - "aarch64" | "arm64ec" => AARCH64_TIED_FEATURES, + match self.arch { + Arch::AArch64 | Arch::Arm64EC => AARCH64_TIED_FEATURES, _ => &[], } } @@ -1038,8 +1050,8 @@ impl Target { // defined by target features. When that is the case, those target features must be // "forbidden" in the list above to ensure that there is a consistent answer to the // questions "which ABI is used". - match &*self.arch { - "x86" => { + match self.arch { + Arch::X86 => { // We use our own ABI indicator here; LLVM does not have anything native. // Every case should require or forbid `soft-float`! match self.rustc_abi { @@ -1064,7 +1076,7 @@ impl Target { } } } - "x86_64" => { + Arch::X86_64 => { // We use our own ABI indicator here; LLVM does not have anything native. // Every case should require or forbid `soft-float`! match self.rustc_abi { @@ -1085,7 +1097,7 @@ impl Target { Some(r) => panic!("invalid Rust ABI for x86_64: {r:?}"), } } - "arm" => { + Arch::Arm => { // On ARM, ABI handling is reasonably sane; we use `llvm_floatabi` to indicate // to LLVM which ABI we are going for. match self.llvm_floatabi.unwrap() { @@ -1102,7 +1114,7 @@ impl Target { } } } - "aarch64" | "arm64ec" => { + Arch::AArch64 | Arch::Arm64EC => { // Aarch64 has no sane ABI specifier, and LLVM doesn't even have a way to force // the use of soft-float, so all we can do here is some crude hacks. match &*self.abi { @@ -1121,7 +1133,7 @@ impl Target { } } } - "riscv32" | "riscv64" => { + Arch::RiscV32 | Arch::RiscV64 => { // RISC-V handles ABI in a very sane way, being fully explicit via `llvm_abiname` // about what the intended ABI is. match &*self.llvm_abiname { @@ -1155,7 +1167,7 @@ impl Target { _ => unreachable!(), } } - "loongarch32" | "loongarch64" => { + Arch::LoongArch32 | Arch::LoongArch64 => { // LoongArch handles ABI in a very sane way, being fully explicit via `llvm_abiname` // about what the intended ABI is. match &*self.llvm_abiname { @@ -1177,7 +1189,7 @@ impl Target { _ => unreachable!(), } } - "s390x" => { + Arch::S390x => { // We don't currently support a softfloat target on this architecture. // As usual, we have to reject swapping the `soft-float` target feature. // The "vector" target feature does not affect the ABI for floats diff --git a/src/tools/miri/src/machine.rs b/src/tools/miri/src/machine.rs index 3b18545fee6c9..27d461f68848b 100644 --- a/src/tools/miri/src/machine.rs +++ b/src/tools/miri/src/machine.rs @@ -31,6 +31,7 @@ use rustc_span::def_id::{CrateNum, DefId}; use rustc_span::{Span, SpanData, Symbol}; use rustc_symbol_mangling::mangle_internal_symbol; use rustc_target::callconv::FnAbi; +use rustc_target::spec::Arch; use crate::alloc_addresses::EvalContextExt; use crate::concurrency::cpu_affinity::{self, CpuAffinityMask}; @@ -716,9 +717,9 @@ impl<'tcx> MiriMachine<'tcx> { page_size } else { let target = &tcx.sess.target; - match target.arch.as_ref() { - "wasm32" | "wasm64" => 64 * 1024, // https://webassembly.github.io/spec/core/exec/runtime.html#memory-instances - "aarch64" => { + match target.arch { + Arch::Wasm32 | Arch::Wasm64 => 64 * 1024, // https://webassembly.github.io/spec/core/exec/runtime.html#memory-instances + Arch::AArch64 => { if target.options.vendor.as_ref() == "apple" { // No "definitive" source, but see: // https://www.wwdcnotes.com/notes/wwdc20/10214/ diff --git a/src/tools/miri/src/shims/alloc.rs b/src/tools/miri/src/shims/alloc.rs index f498a21c9f902..f85ca4cfa4245 100644 --- a/src/tools/miri/src/shims/alloc.rs +++ b/src/tools/miri/src/shims/alloc.rs @@ -3,6 +3,7 @@ use rustc_ast::expand::allocator::SpecialAllocatorMethod; use rustc_middle::ty::Ty; use rustc_span::Symbol; use rustc_target::callconv::FnAbi; +use rustc_target::spec::Arch; use crate::*; @@ -19,14 +20,40 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { // `library/std/src/sys/alloc/mod.rs` (where this is called `MIN_ALIGN`) and should // be kept in sync. let os = this.tcx.sess.target.os.as_ref(); - let max_fundamental_align = match this.tcx.sess.target.arch.as_ref() { - "riscv32" if matches!(os, "espidf" | "zkvm") => 4, - "xtensa" if matches!(os, "espidf") => 4, - "x86" | "arm" | "m68k" | "csky" | "loongarch32" | "mips" | "mips32r6" | "powerpc" - | "powerpc64" | "sparc" | "wasm32" | "hexagon" | "riscv32" | "xtensa" => 8, - "x86_64" | "aarch64" | "arm64ec" | "loongarch64" | "mips64" | "mips64r6" | "s390x" - | "sparc64" | "riscv64" | "wasm64" => 16, - arch => bug!("unsupported target architecture for malloc: `{}`", arch), + let max_fundamental_align = match this.tcx.sess.target.arch { + Arch::RiscV32 if matches!(os, "espidf" | "zkvm") => 4, + Arch::Xtensa if matches!(os, "espidf") => 4, + Arch::X86 + | Arch::Arm + | Arch::M68k + | Arch::CSky + | Arch::LoongArch32 + | Arch::Mips + | Arch::Mips32r6 + | Arch::PowerPC + | Arch::PowerPC64 + | Arch::Sparc + | Arch::Wasm32 + | Arch::Hexagon + | Arch::RiscV32 + | Arch::Xtensa => 8, + Arch::X86_64 + | Arch::AArch64 + | Arch::Arm64EC + | Arch::LoongArch64 + | Arch::Mips64 + | Arch::Mips64r6 + | Arch::S390x + | Arch::Sparc64 + | Arch::RiscV64 + | Arch::Wasm64 => 16, + arch @ (Arch::AmdGpu + | Arch::Avr + | Arch::Bpf + | Arch::Msp430 + | Arch::Nvptx64 + | Arch::PowerPC64LE + | Arch::SpirV) => bug!("unsupported target architecture for malloc: `{arch}`"), }; // The C standard only requires sufficient alignment for any *type* with size less than or // equal to the size requested. Types one can define in standard C seem to never have an alignment diff --git a/src/tools/miri/src/shims/foreign_items.rs b/src/tools/miri/src/shims/foreign_items.rs index 74a1ac729e88f..2507e0f6bbfa1 100644 --- a/src/tools/miri/src/shims/foreign_items.rs +++ b/src/tools/miri/src/shims/foreign_items.rs @@ -15,6 +15,7 @@ use rustc_middle::{mir, ty}; use rustc_session::config::OomStrategy; use rustc_span::Symbol; use rustc_target::callconv::FnAbi; +use rustc_target::spec::Arch; use super::alloc::EvalContextExt as _; use super::backtrace::EvalContextExt as _; @@ -800,20 +801,24 @@ trait EvalContextExtPriv<'tcx>: crate::MiriInterpCxExt<'tcx> { // Target-specific shims name if name.starts_with("llvm.x86.") - && (this.tcx.sess.target.arch == "x86" - || this.tcx.sess.target.arch == "x86_64") => + && matches!( + this.tcx.sess.target.arch, + Arch::X86 | Arch::X86_64 + ) => { return shims::x86::EvalContextExt::emulate_x86_intrinsic( this, link_name, abi, args, dest, ); } - name if name.starts_with("llvm.aarch64.") && this.tcx.sess.target.arch == "aarch64" => { + name if name.starts_with("llvm.aarch64.") + && this.tcx.sess.target.arch == Arch::AArch64 => + { return shims::aarch64::EvalContextExt::emulate_aarch64_intrinsic( this, link_name, abi, args, dest, ); } // FIXME: Move this to an `arm` submodule. - "llvm.arm.hint" if this.tcx.sess.target.arch == "arm" => { + "llvm.arm.hint" if this.tcx.sess.target.arch == Arch::Arm => { let [arg] = this.check_shim_sig_lenient(abi, CanonAbi::C, link_name, args)?; let arg = this.read_scalar(arg)?.to_i32()?; // Note that different arguments might have different target feature requirements. diff --git a/src/tools/miri/src/shims/windows/foreign_items.rs b/src/tools/miri/src/shims/windows/foreign_items.rs index c3ca01bbf3403..21c9022737bc1 100644 --- a/src/tools/miri/src/shims/windows/foreign_items.rs +++ b/src/tools/miri/src/shims/windows/foreign_items.rs @@ -6,6 +6,7 @@ use rustc_abi::{Align, CanonAbi, Size, X86Call}; use rustc_middle::ty::Ty; use rustc_span::Symbol; use rustc_target::callconv::FnAbi; +use rustc_target::spec::Arch; use self::shims::windows::handle::{Handle, PseudoHandle}; use crate::shims::os_str::bytes_to_os_str; @@ -140,7 +141,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { // https://github.com/rust-lang/rust/blob/fb00adbdb69266f10df95a4527b767b0ad35ea48/compiler/rustc_target/src/spec/mod.rs#L2766-L2768, // x86-32 Windows uses a different calling convention than other Windows targets // for the "system" ABI. - let sys_conv = if this.tcx.sess.target.arch == "x86" { + let sys_conv = if this.tcx.sess.target.arch == Arch::X86 { CanonAbi::X86(X86Call::Stdcall) } else { CanonAbi::C diff --git a/src/tools/miri/src/shims/x86/bmi.rs b/src/tools/miri/src/shims/x86/bmi.rs index 140e31cc51333..814823d2acb17 100644 --- a/src/tools/miri/src/shims/x86/bmi.rs +++ b/src/tools/miri/src/shims/x86/bmi.rs @@ -2,6 +2,7 @@ use rustc_abi::CanonAbi; use rustc_middle::ty::Ty; use rustc_span::Symbol; use rustc_target::callconv::FnAbi; +use rustc_target::spec::Arch; use crate::*; @@ -31,7 +32,7 @@ pub(super) trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { let target_feature = if unprefixed_name == "bextr" { "bmi1" } else { "bmi2" }; this.expect_target_feature_for_intrinsic(link_name, target_feature)?; - if is_64_bit && this.tcx.sess.target.arch != "x86_64" { + if is_64_bit && this.tcx.sess.target.arch != Arch::X86_64 { return interp_ok(EmulateItemResult::NotSupported); } diff --git a/src/tools/miri/src/shims/x86/mod.rs b/src/tools/miri/src/shims/x86/mod.rs index 3324b7b024ace..016cb762cece1 100644 --- a/src/tools/miri/src/shims/x86/mod.rs +++ b/src/tools/miri/src/shims/x86/mod.rs @@ -5,6 +5,7 @@ use rustc_middle::ty::Ty; use rustc_middle::{mir, ty}; use rustc_span::Symbol; use rustc_target::callconv::FnAbi; +use rustc_target::spec::Arch; use self::helpers::bool_to_simd_element; use crate::*; @@ -41,7 +42,9 @@ pub(super) trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { // https://www.intel.com/content/www/us/en/docs/cpp-compiler/developer-guide-reference/2021-8/addcarry-u32-addcarry-u64.html // https://www.intel.com/content/www/us/en/docs/cpp-compiler/developer-guide-reference/2021-8/subborrow-u32-subborrow-u64.html "addcarry.32" | "addcarry.64" | "subborrow.32" | "subborrow.64" => { - if unprefixed_name.ends_with("64") && this.tcx.sess.target.arch != "x86_64" { + if unprefixed_name.ends_with("64") + && this.tcx.sess.target.arch != Arch::X86_64 + { return interp_ok(EmulateItemResult::NotSupported); } @@ -65,7 +68,7 @@ pub(super) trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { this.expect_target_feature_for_intrinsic(link_name, "adx")?; let is_u64 = unprefixed_name.ends_with("64"); - if is_u64 && this.tcx.sess.target.arch != "x86_64" { + if is_u64 && this.tcx.sess.target.arch != Arch::X86_64 { return interp_ok(EmulateItemResult::NotSupported); } let [c_in, a, b, out] = diff --git a/src/tools/miri/src/shims/x86/sse42.rs b/src/tools/miri/src/shims/x86/sse42.rs index 72c5039a12d3c..aa8aea3558832 100644 --- a/src/tools/miri/src/shims/x86/sse42.rs +++ b/src/tools/miri/src/shims/x86/sse42.rs @@ -3,6 +3,7 @@ use rustc_middle::mir; use rustc_middle::ty::Ty; use rustc_span::Symbol; use rustc_target::callconv::FnAbi; +use rustc_target::spec::Arch; use crate::*; @@ -431,7 +432,7 @@ pub(super) trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { _ => unreachable!(), }; - if bit_size == 64 && this.tcx.sess.target.arch != "x86_64" { + if bit_size == 64 && this.tcx.sess.target.arch != Arch::X86_64 { return interp_ok(EmulateItemResult::NotSupported); } From 0c8533d6905a9369d810b4add1efc0c52098cc9e Mon Sep 17 00:00:00 2001 From: Tamir Duberstein Date: Mon, 13 Oct 2025 16:49:29 -0400 Subject: [PATCH 4/5] compiler: intern architecture at compile time --- compiler/rustc_session/src/config/cfg.rs | 4 +-- compiler/rustc_span/src/symbol.rs | 30 +++++++++++++++++++ compiler/rustc_target/src/spec/mod.rs | 38 ++++++++++++++++++++++++ 3 files changed, 70 insertions(+), 2 deletions(-) diff --git a/compiler/rustc_session/src/config/cfg.rs b/compiler/rustc_session/src/config/cfg.rs index 9cb25ad11aacb..4654527490245 100644 --- a/compiler/rustc_session/src/config/cfg.rs +++ b/compiler/rustc_session/src/config/cfg.rs @@ -240,7 +240,7 @@ pub(crate) fn default_configuration(sess: &Session) -> Cfg { } ins_str!(sym::target_abi, &sess.target.abi); - ins_str!(sym::target_arch, sess.target.arch.desc()); + ins_sym!(sym::target_arch, sess.target.arch.desc_symbol()); ins_str!(sym::target_endian, sess.target.endian.as_str()); ins_str!(sym::target_env, &sess.target.env); @@ -448,7 +448,7 @@ impl CheckCfg { for target in Target::builtins().chain(iter::once(current_target.clone())) { values_target_abi.insert(Symbol::intern(&target.options.abi)); - values_target_arch.insert(Symbol::intern(target.arch.desc())); + values_target_arch.insert(target.arch.desc_symbol()); values_target_endian.insert(Symbol::intern(target.options.endian.as_str())); values_target_env.insert(Symbol::intern(&target.options.env)); values_target_family.extend( diff --git a/compiler/rustc_span/src/symbol.rs b/compiler/rustc_span/src/symbol.rs index 86b6bb16835b9..38718bad9e57e 100644 --- a/compiler/rustc_span/src/symbol.rs +++ b/compiler/rustc_span/src/symbol.rs @@ -400,6 +400,7 @@ symbols! { _t, _task_context, a32, + aarch64, aarch64_target_feature, aarch64_unstable_target_feature, aarch64_ver_target_feature, @@ -449,6 +450,7 @@ symbols! { altivec, alu32, always, + amdgpu, analysis, and, and_then, @@ -466,6 +468,7 @@ symbols! { args, arith_offset, arm, + arm64ec, arm_target_feature, array, as_dash_needed: "as-needed", @@ -555,6 +558,7 @@ symbols! { autodiff_reverse, automatically_derived, available_externally, + avr, avx, avx10_target_feature, avx512_target_feature, @@ -587,6 +591,7 @@ symbols! { box_patterns, box_syntax, boxed_slice, + bpf, bpf_target_feature, braced_empty_structs, branch, @@ -791,6 +796,7 @@ symbols! { crate_type, crate_visibility_modifier, crt_dash_static: "crt-static", + csky, csky_target_feature, cstr_type, cstring_as_c_str, @@ -1157,6 +1163,7 @@ symbols! { hashset_drain_ty, hashset_iter, hashset_iter_ty, + hexagon, hexagon_target_feature, hidden, hide, @@ -1343,11 +1350,14 @@ symbols! { logf32, logf64, logf128, + loongarch32, + loongarch64, loongarch_target_feature, loop_break_value, loop_match, lr, lt, + m68k, m68k_target_feature, macro_at_most_once_rep, macro_attr, @@ -1423,6 +1433,10 @@ symbols! { minnumf32, minnumf64, minnumf128, + mips, + mips32r6, + mips64, + mips64r6, mips_target_feature, mir_assume, mir_basic_block, @@ -1471,6 +1485,7 @@ symbols! { move_ref_pattern, move_size_limit, movrs_target_feature, + msp430, mul, mul_assign, mul_with_overflow, @@ -1558,6 +1573,7 @@ symbols! { notable_trait, note, null, + nvptx64, nvptx_target_feature, object_safe_for_dispatch, of, @@ -1683,6 +1699,9 @@ symbols! { post_cleanup: "post-cleanup", post_dash_lto: "post-lto", postfix_match, + powerpc, + powerpc64, + powerpc64le, powerpc_target_feature, powf16, powf32, @@ -1830,6 +1849,8 @@ symbols! { resume, return_position_impl_trait_in_trait, return_type_notation, + riscv32, + riscv64, riscv_target_feature, rlib, ropi, @@ -1977,6 +1998,7 @@ symbols! { rvalue_static_promotion, rwpi, s, + s390x, s390x_target_feature, safety, sanitize, @@ -2105,9 +2127,12 @@ symbols! { slice_patterns, slicing_syntax, soft, + sparc, + sparc64, sparc_target_feature, specialization, speed, + spirv, spotlight, sqrtf16, sqrtf32, @@ -2422,6 +2447,8 @@ symbols! { vtable_size, warn, wasip2, + wasm32, + wasm64, wasm_abi, wasm_import_module, wasm_target_feature, @@ -2448,12 +2475,15 @@ symbols! { write_str, write_via_move, writeln_macro, + x86, + x86_64, x86_amx_intrinsics, x87_reg, x87_target_feature, xer, xmm_reg, xop_target_feature, + xtensa, yeet_desugar_details, yeet_expr, yes, diff --git a/compiler/rustc_target/src/spec/mod.rs b/compiler/rustc_target/src/spec/mod.rs index 892be1e18ca2e..7f3fea1d7da7e 100644 --- a/compiler/rustc_target/src/spec/mod.rs +++ b/compiler/rustc_target/src/spec/mod.rs @@ -1885,6 +1885,44 @@ crate::target_spec_enum! { parse_error_type = "architecture"; } +impl Arch { + pub const fn desc_symbol(&self) -> Symbol { + match self { + Self::AArch64 => sym::aarch64, + Self::AmdGpu => sym::amdgpu, + Self::Arm => sym::arm, + Self::Arm64EC => sym::arm64ec, + Self::Avr => sym::avr, + Self::Bpf => sym::bpf, + Self::CSky => sym::csky, + Self::Hexagon => sym::hexagon, + Self::LoongArch32 => sym::loongarch32, + Self::LoongArch64 => sym::loongarch64, + Self::M68k => sym::m68k, + Self::Mips => sym::mips, + Self::Mips32r6 => sym::mips32r6, + Self::Mips64 => sym::mips64, + Self::Mips64r6 => sym::mips64r6, + Self::Msp430 => sym::msp430, + Self::Nvptx64 => sym::nvptx64, + Self::PowerPC => sym::powerpc, + Self::PowerPC64 => sym::powerpc64, + Self::PowerPC64LE => sym::powerpc64le, + Self::RiscV32 => sym::riscv32, + Self::RiscV64 => sym::riscv64, + Self::S390x => sym::s390x, + Self::Sparc => sym::sparc, + Self::Sparc64 => sym::sparc64, + Self::SpirV => sym::spirv, + Self::Wasm32 => sym::wasm32, + Self::Wasm64 => sym::wasm64, + Self::X86 => sym::x86, + Self::X86_64 => sym::x86_64, + Self::Xtensa => sym::xtensa, + } + } +} + /// Everything `rustc` knows about how to compile for a specific target. /// /// Every field here must be specified, and has no default value. From 26b0560b6db4f7116809c81532c2d64f43b74998 Mon Sep 17 00:00:00 2001 From: Tamir Duberstein Date: Tue, 28 Oct 2025 19:48:56 -0400 Subject: [PATCH 5/5] rustc_target: allow unenumerated architectures --- .../rustc_codegen_cranelift/src/abi/mod.rs | 2 +- compiler/rustc_codegen_gcc/src/abi.rs | 8 +-- compiler/rustc_codegen_gcc/src/context.rs | 2 +- compiler/rustc_codegen_gcc/src/gcc_util.rs | 62 +++++++++---------- compiler/rustc_codegen_llvm/src/abi.rs | 2 +- compiler/rustc_codegen_llvm/src/llvm_util.rs | 2 +- .../rustc_codegen_ssa/src/back/archive.rs | 4 +- compiler/rustc_codegen_ssa/src/base.rs | 2 +- compiler/rustc_session/src/session.rs | 2 +- compiler/rustc_target/src/asm/mod.rs | 4 +- compiler/rustc_target/src/callconv/mod.rs | 6 +- compiler/rustc_target/src/lib.rs | 61 ++++++++++++++++++ .../rustc_target/src/spec/base/apple/mod.rs | 2 +- compiler/rustc_target/src/spec/mod.rs | 16 +++-- compiler/rustc_target/src/target_features.rs | 14 +++-- compiler/rustc_target/src/tests.rs | 25 ++++++++ src/tools/miri/src/shims/alloc.rs | 5 +- tests/ui/check-cfg/my-awesome-platform.json | 2 +- tests/ui/check-cfg/values-target-json.rs | 15 +++-- 19 files changed, 169 insertions(+), 67 deletions(-) diff --git a/compiler/rustc_codegen_cranelift/src/abi/mod.rs b/compiler/rustc_codegen_cranelift/src/abi/mod.rs index 6ea26b02c2619..d7f17795815de 100644 --- a/compiler/rustc_codegen_cranelift/src/abi/mod.rs +++ b/compiler/rustc_codegen_cranelift/src/abi/mod.rs @@ -788,7 +788,7 @@ pub(crate) fn codegen_drop<'tcx>( pub(crate) fn lib_call_arg_param(tcx: TyCtxt<'_>, ty: Type, is_signed: bool) -> AbiParam { let param = AbiParam::new(ty); if ty.is_int() && u64::from(ty.bits()) < tcx.data_layout.pointer_size().bits() { - match (tcx.sess.target.arch, tcx.sess.target.vendor.as_ref()) { + match (&tcx.sess.target.arch, tcx.sess.target.vendor.as_ref()) { (Arch::X86_64, _) | (Arch::AArch64, "apple") => match (ty, is_signed) { (types::I8 | types::I16, true) => param.sext(), (types::I8 | types::I16, false) => param.uext(), diff --git a/compiler/rustc_codegen_gcc/src/abi.rs b/compiler/rustc_codegen_gcc/src/abi.rs index b7d0e19ee2725..bcc28e476dba9 100644 --- a/compiler/rustc_codegen_gcc/src/abi.rs +++ b/compiler/rustc_codegen_gcc/src/abi.rs @@ -235,12 +235,12 @@ impl<'gcc, 'tcx> FnAbiGccExt<'gcc, 'tcx> for FnAbi<'tcx, Ty<'tcx>> { #[cfg(feature = "master")] fn gcc_cconv(&self, cx: &CodegenCx<'gcc, 'tcx>) -> Option> { - conv_to_fn_attribute(self.conv, cx.tcx.sess.target.arch) + conv_to_fn_attribute(self.conv, &cx.tcx.sess.target.arch) } } #[cfg(feature = "master")] -pub fn conv_to_fn_attribute<'gcc>(conv: CanonAbi, arch: Arch) -> Option> { +pub fn conv_to_fn_attribute<'gcc>(conv: CanonAbi, arch: &Arch) -> Option> { let attribute = match conv { CanonAbi::C | CanonAbi::Rust => return None, CanonAbi::RustCold => FnAttribute::Cold, @@ -254,8 +254,8 @@ pub fn conv_to_fn_attribute<'gcc>(conv: CanonAbi, arch: Arch) -> Option FnAttribute::ArmPcs("aapcs"), }, CanonAbi::GpuKernel => match arch { - Arch::AmdGpu => FnAttribute::GcnAmdGpuHsaKernel, - Arch::Nvptx64 => FnAttribute::NvptxKernel, + &Arch::AmdGpu => FnAttribute::GcnAmdGpuHsaKernel, + &Arch::Nvptx64 => FnAttribute::NvptxKernel, arch => panic!("Arch {arch} does not support GpuKernel calling convention"), }, // TODO(antoyo): check if those AVR attributes are mapped correctly. diff --git a/compiler/rustc_codegen_gcc/src/context.rs b/compiler/rustc_codegen_gcc/src/context.rs index 6084b4fc07fac..c9ae96777de44 100644 --- a/compiler/rustc_codegen_gcc/src/context.rs +++ b/compiler/rustc_codegen_gcc/src/context.rs @@ -487,7 +487,7 @@ impl<'gcc, 'tcx> MiscCodegenMethods<'tcx> for CodegenCx<'gcc, 'tcx> { let entry_name = self.sess().target.entry_name.as_ref(); if !self.functions.borrow().contains_key(entry_name) { #[cfg(feature = "master")] - let conv = conv_to_fn_attribute(self.sess().target.entry_abi, self.sess().target.arch); + let conv = conv_to_fn_attribute(self.sess().target.entry_abi, &self.sess().target.arch); #[cfg(not(feature = "master"))] let conv = None; Some(self.declare_entry_fn(entry_name, fn_type, conv)) diff --git a/compiler/rustc_codegen_gcc/src/gcc_util.rs b/compiler/rustc_codegen_gcc/src/gcc_util.rs index 83d54472e5ded..e33b6c92d6371 100644 --- a/compiler/rustc_codegen_gcc/src/gcc_util.rs +++ b/compiler/rustc_codegen_gcc/src/gcc_util.rs @@ -67,46 +67,46 @@ pub(crate) fn global_gcc_features(sess: &Session, diagnostics: bool) -> Vec(sess: &Session, s: &'a str) -> SmallVec<[&'a str; 2]> { // cSpell:disable - match (sess.target.arch, s) { + match (&sess.target.arch, s) { // FIXME: seems like x87 does not exist? - (Arch::X86 | Arch::X86_64, "x87") => smallvec![], - (Arch::X86 | Arch::X86_64, "sse4.2") => smallvec!["sse4.2", "crc32"], - (Arch::X86 | Arch::X86_64, "pclmulqdq") => smallvec!["pclmul"], - (Arch::X86 | Arch::X86_64, "rdrand") => smallvec!["rdrnd"], - (Arch::X86 | Arch::X86_64, "bmi1") => smallvec!["bmi"], - (Arch::X86 | Arch::X86_64, "cmpxchg16b") => smallvec!["cx16"], - (Arch::X86 | Arch::X86_64, "avx512vaes") => smallvec!["vaes"], - (Arch::X86 | Arch::X86_64, "avx512gfni") => smallvec!["gfni"], - (Arch::X86 | Arch::X86_64, "avx512vpclmulqdq") => smallvec!["vpclmulqdq"], + (&Arch::X86 | &Arch::X86_64, "x87") => smallvec![], + (&Arch::X86 | &Arch::X86_64, "sse4.2") => smallvec!["sse4.2", "crc32"], + (&Arch::X86 | &Arch::X86_64, "pclmulqdq") => smallvec!["pclmul"], + (&Arch::X86 | &Arch::X86_64, "rdrand") => smallvec!["rdrnd"], + (&Arch::X86 | &Arch::X86_64, "bmi1") => smallvec!["bmi"], + (&Arch::X86 | &Arch::X86_64, "cmpxchg16b") => smallvec!["cx16"], + (&Arch::X86 | &Arch::X86_64, "avx512vaes") => smallvec!["vaes"], + (&Arch::X86 | &Arch::X86_64, "avx512gfni") => smallvec!["gfni"], + (&Arch::X86 | &Arch::X86_64, "avx512vpclmulqdq") => smallvec!["vpclmulqdq"], // NOTE: seems like GCC requires 'avx512bw' for 'avx512vbmi2'. - (Arch::X86 | Arch::X86_64, "avx512vbmi2") => { + (&Arch::X86 | &Arch::X86_64, "avx512vbmi2") => { smallvec!["avx512vbmi2", "avx512bw"] } // NOTE: seems like GCC requires 'avx512bw' for 'avx512bitalg'. - (Arch::X86 | Arch::X86_64, "avx512bitalg") => { + (&Arch::X86 | &Arch::X86_64, "avx512bitalg") => { smallvec!["avx512bitalg", "avx512bw"] } - (Arch::AArch64, "rcpc2") => smallvec!["rcpc-immo"], - (Arch::AArch64, "dpb") => smallvec!["ccpp"], - (Arch::AArch64, "dpb2") => smallvec!["ccdp"], - (Arch::AArch64, "frintts") => smallvec!["fptoint"], - (Arch::AArch64, "fcma") => smallvec!["complxnum"], - (Arch::AArch64, "pmuv3") => smallvec!["perfmon"], - (Arch::AArch64, "paca") => smallvec!["pauth"], - (Arch::AArch64, "pacg") => smallvec!["pauth"], + (&Arch::AArch64, "rcpc2") => smallvec!["rcpc-immo"], + (&Arch::AArch64, "dpb") => smallvec!["ccpp"], + (&Arch::AArch64, "dpb2") => smallvec!["ccdp"], + (&Arch::AArch64, "frintts") => smallvec!["fptoint"], + (&Arch::AArch64, "fcma") => smallvec!["complxnum"], + (&Arch::AArch64, "pmuv3") => smallvec!["perfmon"], + (&Arch::AArch64, "paca") => smallvec!["pauth"], + (&Arch::AArch64, "pacg") => smallvec!["pauth"], // Rust ties fp and neon together. In GCC neon implicitly enables fp, // but we manually enable neon when a feature only implicitly enables fp - (Arch::AArch64, "f32mm") => smallvec!["f32mm", "neon"], - (Arch::AArch64, "f64mm") => smallvec!["f64mm", "neon"], - (Arch::AArch64, "fhm") => smallvec!["fp16fml", "neon"], - (Arch::AArch64, "fp16") => smallvec!["fullfp16", "neon"], - (Arch::AArch64, "jsconv") => smallvec!["jsconv", "neon"], - (Arch::AArch64, "sve") => smallvec!["sve", "neon"], - (Arch::AArch64, "sve2") => smallvec!["sve2", "neon"], - (Arch::AArch64, "sve2-aes") => smallvec!["sve2-aes", "neon"], - (Arch::AArch64, "sve2-sm4") => smallvec!["sve2-sm4", "neon"], - (Arch::AArch64, "sve2-sha3") => smallvec!["sve2-sha3", "neon"], - (Arch::AArch64, "sve2-bitperm") => smallvec!["sve2-bitperm", "neon"], + (&Arch::AArch64, "f32mm") => smallvec!["f32mm", "neon"], + (&Arch::AArch64, "f64mm") => smallvec!["f64mm", "neon"], + (&Arch::AArch64, "fhm") => smallvec!["fp16fml", "neon"], + (&Arch::AArch64, "fp16") => smallvec!["fullfp16", "neon"], + (&Arch::AArch64, "jsconv") => smallvec!["jsconv", "neon"], + (&Arch::AArch64, "sve") => smallvec!["sve", "neon"], + (&Arch::AArch64, "sve2") => smallvec!["sve2", "neon"], + (&Arch::AArch64, "sve2-aes") => smallvec!["sve2-aes", "neon"], + (&Arch::AArch64, "sve2-sm4") => smallvec!["sve2-sm4", "neon"], + (&Arch::AArch64, "sve2-sha3") => smallvec!["sve2-sha3", "neon"], + (&Arch::AArch64, "sve2-bitperm") => smallvec!["sve2-bitperm", "neon"], (_, s) => smallvec![s], } // cSpell:enable diff --git a/compiler/rustc_codegen_llvm/src/abi.rs b/compiler/rustc_codegen_llvm/src/abi.rs index b045af3161dc2..e6b76f74158b8 100644 --- a/compiler/rustc_codegen_llvm/src/abi.rs +++ b/compiler/rustc_codegen_llvm/src/abi.rs @@ -698,7 +698,7 @@ pub(crate) fn to_llvm_calling_convention(sess: &Session, abi: CanonAbi) -> llvm: // possible to declare an `extern "custom"` block, so the backend still needs a calling // convention for declaring foreign functions. CanonAbi::Custom => llvm::CCallConv, - CanonAbi::GpuKernel => match sess.target.arch { + CanonAbi::GpuKernel => match &sess.target.arch { Arch::AmdGpu => llvm::AmdgpuKernel, Arch::Nvptx64 => llvm::PtxKernel, arch => panic!("Architecture {arch} does not support GpuKernel calling convention"), diff --git a/compiler/rustc_codegen_llvm/src/llvm_util.rs b/compiler/rustc_codegen_llvm/src/llvm_util.rs index 8f8a3a3aef2ff..32ea3987f968d 100644 --- a/compiler/rustc_codegen_llvm/src/llvm_util.rs +++ b/compiler/rustc_codegen_llvm/src/llvm_util.rs @@ -342,7 +342,7 @@ pub(crate) fn target_config(sess: &Session) -> TargetConfig { /// Determine whether or not experimental float types are reliable based on known bugs. fn update_target_reliable_float_cfg(sess: &Session, cfg: &mut TargetConfig) { - let target_arch = sess.target.arch; + let target_arch = &sess.target.arch; let target_os = sess.target.options.os.as_ref(); let target_env = sess.target.options.env.as_ref(); let target_abi = sess.target.options.abi.as_ref(); diff --git a/compiler/rustc_codegen_ssa/src/back/archive.rs b/compiler/rustc_codegen_ssa/src/back/archive.rs index cef7df44abe30..93f6cb3b87e66 100644 --- a/compiler/rustc_codegen_ssa/src/back/archive.rs +++ b/compiler/rustc_codegen_ssa/src/back/archive.rs @@ -118,7 +118,7 @@ pub trait ArchiveBuilderBuilder { let exports = items.into_iter().map(|item| item.into_coff_short_export(sess)).collect::>(); - let machine = match sess.target.arch { + let machine = match &sess.target.arch { Arch::X86_64 => MachineTypes::AMD64, Arch::X86 => MachineTypes::I386, Arch::AArch64 => MachineTypes::ARM64, @@ -224,7 +224,7 @@ fn create_mingw_dll_import_lib( }; // dlltool target architecture args from: // https://github.com/llvm/llvm-project-release-prs/blob/llvmorg-15.0.6/llvm/lib/ToolDrivers/llvm-dlltool/DlltoolDriver.cpp#L69 - let (dlltool_target_arch, dlltool_target_bitness) = match sess.target.arch { + let (dlltool_target_arch, dlltool_target_bitness) = match &sess.target.arch { Arch::X86_64 => ("i386:x86-64", "--64"), Arch::X86 => ("i386", "--32"), Arch::AArch64 => ("arm64", "--64"), diff --git a/compiler/rustc_codegen_ssa/src/base.rs b/compiler/rustc_codegen_ssa/src/base.rs index a500547587291..ed2815b06c18a 100644 --- a/compiler/rustc_codegen_ssa/src/base.rs +++ b/compiler/rustc_codegen_ssa/src/base.rs @@ -983,7 +983,7 @@ impl CrateInfo { // by the compiler, but that's ok because all this stuff is unstable anyway. let target = &tcx.sess.target; if !are_upstream_rust_objects_already_included(tcx.sess) { - let add_prefix = match (target.is_like_windows, target.arch) { + let add_prefix = match (target.is_like_windows, &target.arch) { (true, Arch::X86) => |name: String, _: SymbolExportKind| format!("_{name}"), (true, Arch::Arm64EC) => { // Only functions are decorated for arm64ec. diff --git a/compiler/rustc_session/src/session.rs b/compiler/rustc_session/src/session.rs index 63d64b410950a..16f9774554e1b 100644 --- a/compiler/rustc_session/src/session.rs +++ b/compiler/rustc_session/src/session.rs @@ -1112,7 +1112,7 @@ pub fn build_session( _ => CtfeBacktrace::Disabled, }); - let asm_arch = if target.allow_asm { InlineAsmArch::from_arch(target.arch) } else { None }; + let asm_arch = if target.allow_asm { InlineAsmArch::from_arch(&target.arch) } else { None }; let target_filesearch = filesearch::FileSearch::new(&sopts.search_paths, &target_tlib_path, &target); let host_filesearch = filesearch::FileSearch::new(&sopts.search_paths, &host_tlib_path, &host); diff --git a/compiler/rustc_target/src/asm/mod.rs b/compiler/rustc_target/src/asm/mod.rs index e5c140a848c34..cd7d9125d7b50 100644 --- a/compiler/rustc_target/src/asm/mod.rs +++ b/compiler/rustc_target/src/asm/mod.rs @@ -245,7 +245,7 @@ pub enum InlineAsmArch { } impl InlineAsmArch { - pub fn from_arch(arch: Arch) -> Option { + pub fn from_arch(arch: &Arch) -> Option { match arch { Arch::X86 => Some(Self::X86), Arch::X86_64 => Some(Self::X86_64), @@ -273,7 +273,7 @@ impl InlineAsmArch { Arch::Msp430 => Some(Self::Msp430), Arch::M68k => Some(Self::M68k), Arch::CSky => Some(Self::CSKY), - Arch::AmdGpu | Arch::Xtensa => None, + Arch::AmdGpu | Arch::Xtensa | Arch::Unknown(_) => None, } } } diff --git a/compiler/rustc_target/src/callconv/mod.rs b/compiler/rustc_target/src/callconv/mod.rs index ef55bc45a7742..43e1ca3ef9cee 100644 --- a/compiler/rustc_target/src/callconv/mod.rs +++ b/compiler/rustc_target/src/callconv/mod.rs @@ -633,7 +633,7 @@ impl<'a, Ty> FnAbi<'a, Ty> { } let spec = cx.target_spec(); - match spec.arch { + match &spec.arch { Arch::X86 => { let (flavor, regparm) = match abi { ExternAbi::Fastcall { .. } | ExternAbi::Vectorcall { .. } => { @@ -701,7 +701,7 @@ impl<'a, Ty> FnAbi<'a, Ty> { Arch::RiscV32 | Arch::RiscV64 => riscv::compute_abi_info(cx, self), Arch::Wasm32 | Arch::Wasm64 => wasm::compute_abi_info(cx, self), Arch::Bpf => bpf::compute_abi_info(cx, self), - arch @ (Arch::PowerPC64LE | Arch::SpirV) => { + arch @ (Arch::PowerPC64LE | Arch::SpirV | Arch::Unknown(_)) => { panic!("no lowering implemented for {arch}") } } @@ -713,7 +713,7 @@ impl<'a, Ty> FnAbi<'a, Ty> { C: HasDataLayout + HasTargetSpec, { let spec = cx.target_spec(); - match spec.arch { + match &spec.arch { Arch::X86 => x86::compute_rust_abi_info(cx, self), Arch::RiscV32 | Arch::RiscV64 => riscv::compute_rust_abi_info(cx, self), Arch::LoongArch32 | Arch::LoongArch64 => loongarch::compute_rust_abi_info(cx, self), diff --git a/compiler/rustc_target/src/lib.rs b/compiler/rustc_target/src/lib.rs index f664bbb874d67..b38ce20e60957 100644 --- a/compiler/rustc_target/src/lib.rs +++ b/compiler/rustc_target/src/lib.rs @@ -118,6 +118,67 @@ macro_rules! target_spec_enum { } } + crate::target_spec_enum!(@common_impls $Name); + }; + + ( + $( #[$attr:meta] )* + pub enum $Name:ident { + $( + $( #[$variant_attr:meta] )* + $Variant:ident = $string:literal, + )* + } + $( #[$other_variant_attr:meta] )* + other_variant = $OtherVariant:ident; + ) => { + $( #[$attr] )* + #[derive(Clone, PartialEq, Eq, Hash, Debug, PartialOrd, Ord)] + pub enum $Name { + $( + $( #[$variant_attr:meta] )* + $Variant, + )* + $( #[$other_variant_attr] )* + $OtherVariant(crate::spec::StaticCow), + } + + impl schemars::JsonSchema for $Name { + fn schema_name() -> std::borrow::Cow<'static, str> { + std::borrow::Cow::Borrowed(stringify!($Name)) + } + + fn json_schema(_: &mut schemars::SchemaGenerator) -> schemars::Schema { + schemars::json_schema!({ + "type": "string" + }) + } + } + + impl FromStr for $Name { + type Err = core::convert::Infallible; + + fn from_str(s: &str) -> Result { + Ok(match s { + $( $string => Self::$Variant, )* + _ => Self::$OtherVariant(s.to_owned().into()), + }) + } + } + + impl $Name { + pub fn desc(&self) -> &str { + match self { + $( Self::$Variant => $string, )* + Self::$OtherVariant(name) => name.as_ref(), + } + } + } + + crate::target_spec_enum!(@common_impls $Name); + }; + + (@common_impls $Name:ident) => { impl crate::json::ToJson for $Name { fn to_json(&self) -> crate::json::Json { self.desc().to_json() diff --git a/compiler/rustc_target/src/spec/base/apple/mod.rs b/compiler/rustc_target/src/spec/base/apple/mod.rs index cf147e48c501e..047bc9b8518b2 100644 --- a/compiler/rustc_target/src/spec/base/apple/mod.rs +++ b/compiler/rustc_target/src/spec/base/apple/mod.rs @@ -311,7 +311,7 @@ impl OSVersion { /// This matches what LLVM does, see in part: /// pub fn minimum_deployment_target(target: &Target) -> Self { - let (major, minor, patch) = match (&*target.os, target.arch, &*target.env) { + let (major, minor, patch) = match (&*target.os, &target.arch, &*target.env) { ("macos", crate::spec::Arch::AArch64, _) => (11, 0, 0), ("ios", crate::spec::Arch::AArch64, "macabi") => (14, 0, 0), ("ios", crate::spec::Arch::AArch64, "sim") => (14, 0, 0), diff --git a/compiler/rustc_target/src/spec/mod.rs b/compiler/rustc_target/src/spec/mod.rs index 7f3fea1d7da7e..74048d351802a 100644 --- a/compiler/rustc_target/src/spec/mod.rs +++ b/compiler/rustc_target/src/spec/mod.rs @@ -1881,12 +1881,18 @@ crate::target_spec_enum! { X86_64 = "x86_64", Xtensa = "xtensa", } - - parse_error_type = "architecture"; + /// The vast majority of the time, the compiler deals with a fixed set of + /// target architectures, so it is convenient for them to be represented in + /// an enum. However, it is possible to have arbitrary values for the "arch" + /// field in a target JSON file (which can be parsed when `--target` is + /// specified). This might occur, for example, for an out-of-tree codegen + /// backend that supports an architecture that rustc currently doesn't know + /// about. This variant exists as an escape hatch for such cases. + other_variant = Unknown; } impl Arch { - pub const fn desc_symbol(&self) -> Symbol { + pub fn desc_symbol(&self) -> Symbol { match self { Self::AArch64 => sym::aarch64, Self::AmdGpu => sym::amdgpu, @@ -1919,6 +1925,7 @@ impl Arch { Self::X86 => sym::x86, Self::X86_64 => sym::x86_64, Self::Xtensa => sym::xtensa, + Self::Unknown(name) => rustc_span::Symbol::intern(name), } } } @@ -3274,7 +3281,8 @@ impl Target { | Arch::PowerPC64LE | Arch::SpirV | Arch::Wasm32 - | Arch::Wasm64 => return None, + | Arch::Wasm64 + | Arch::Unknown(_) => return None, }) } diff --git a/compiler/rustc_target/src/target_features.rs b/compiler/rustc_target/src/target_features.rs index 16c3558d535b3..fd95bd062be65 100644 --- a/compiler/rustc_target/src/target_features.rs +++ b/compiler/rustc_target/src/target_features.rs @@ -955,7 +955,7 @@ pub struct FeatureConstraints { impl Target { pub fn rust_target_features(&self) -> &'static [(&'static str, Stability, ImpliedFeatures)] { - match self.arch { + match &self.arch { Arch::Arm => ARM_FEATURES, Arch::AArch64 | Arch::Arm64EC => AARCH64_FEATURES, Arch::X86 | Arch::X86_64 => X86_FEATURES, @@ -976,12 +976,13 @@ impl Target { | Arch::Msp430 | Arch::PowerPC64LE | Arch::SpirV - | Arch::Xtensa => &[], + | Arch::Xtensa + | Arch::Unknown(_) => &[], } } pub fn features_for_correct_vector_abi(&self) -> &'static [(u64, &'static str)] { - match self.arch { + match &self.arch { Arch::X86 | Arch::X86_64 => X86_FEATURES_FOR_CORRECT_VECTOR_ABI, Arch::AArch64 | Arch::Arm64EC => AARCH64_FEATURES_FOR_CORRECT_VECTOR_ABI, Arch::Arm => ARM_FEATURES_FOR_CORRECT_VECTOR_ABI, @@ -1004,12 +1005,13 @@ impl Target { | Arch::Msp430 | Arch::PowerPC64LE | Arch::SpirV - | Arch::Xtensa => &[], + | Arch::Xtensa + | Arch::Unknown(_) => &[], } } pub fn tied_target_features(&self) -> &'static [&'static [&'static str]] { - match self.arch { + match &self.arch { Arch::AArch64 | Arch::Arm64EC => AARCH64_TIED_FEATURES, _ => &[], } @@ -1050,7 +1052,7 @@ impl Target { // defined by target features. When that is the case, those target features must be // "forbidden" in the list above to ensure that there is a consistent answer to the // questions "which ABI is used". - match self.arch { + match &self.arch { Arch::X86 => { // We use our own ABI indicator here; LLVM does not have anything native. // Every case should require or forbid `soft-float`! diff --git a/compiler/rustc_target/src/tests.rs b/compiler/rustc_target/src/tests.rs index a2692ea6be5e0..bb17dd151b58d 100644 --- a/compiler/rustc_target/src/tests.rs +++ b/compiler/rustc_target/src/tests.rs @@ -1,3 +1,4 @@ +use crate::json::ToJson; use crate::spec::Target; #[test] @@ -15,3 +16,27 @@ fn report_unused_fields() { eprintln!("{result:#?}"); assert!(result.is_err()); } + +#[test] +fn custom_arch_propagates_from_json() { + let json = r#" + { + "llvm-target": "x86_64-unknown-none-gnu", + "data-layout": "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128", + "arch": "customarch", + "target-endian": "little", + "target-pointer-width": 64, + "os": "customos", + "linker-flavor": "ld.lld", + "linker": "rust-lld", + "executables": true + } + "#; + rustc_span::create_session_if_not_set_then(rustc_span::edition::DEFAULT_EDITION, |_| { + let (target, warnings) = Target::from_json(json).expect("json target parses"); + assert!(warnings.warning_messages().is_empty()); + assert_eq!(target.arch.desc(), "customarch"); + let serialized = target.to_json(); + assert_eq!(serialized["arch"], "customarch"); + }); +} diff --git a/src/tools/miri/src/shims/alloc.rs b/src/tools/miri/src/shims/alloc.rs index f85ca4cfa4245..217069b8b5d95 100644 --- a/src/tools/miri/src/shims/alloc.rs +++ b/src/tools/miri/src/shims/alloc.rs @@ -20,7 +20,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { // `library/std/src/sys/alloc/mod.rs` (where this is called `MIN_ALIGN`) and should // be kept in sync. let os = this.tcx.sess.target.os.as_ref(); - let max_fundamental_align = match this.tcx.sess.target.arch { + let max_fundamental_align = match &this.tcx.sess.target.arch { Arch::RiscV32 if matches!(os, "espidf" | "zkvm") => 4, Arch::Xtensa if matches!(os, "espidf") => 4, Arch::X86 @@ -53,7 +53,8 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { | Arch::Msp430 | Arch::Nvptx64 | Arch::PowerPC64LE - | Arch::SpirV) => bug!("unsupported target architecture for malloc: `{arch}`"), + | Arch::SpirV + | Arch::Unknown(_)) => bug!("unsupported target architecture for malloc: `{arch}`"), }; // The C standard only requires sufficient alignment for any *type* with size less than or // equal to the size requested. Types one can define in standard C seem to never have an alignment diff --git a/tests/ui/check-cfg/my-awesome-platform.json b/tests/ui/check-cfg/my-awesome-platform.json index 3a1f6b1a54c61..c3b3b89a08cf8 100644 --- a/tests/ui/check-cfg/my-awesome-platform.json +++ b/tests/ui/check-cfg/my-awesome-platform.json @@ -1,7 +1,7 @@ { "llvm-target": "x86_64-unknown-none-gnu", "data-layout": "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128", - "arch": "x86_64", + "arch": "tamirdarch", "target-endian": "little", "target-pointer-width": 64, "os": "ericos", diff --git a/tests/ui/check-cfg/values-target-json.rs b/tests/ui/check-cfg/values-target-json.rs index ddfcb24c640c5..2912c83b58de5 100644 --- a/tests/ui/check-cfg/values-target-json.rs +++ b/tests/ui/check-cfg/values-target-json.rs @@ -6,14 +6,19 @@ //@ needs-llvm-components: x86 //@ compile-flags: --crate-type=lib --check-cfg=cfg() --target={{src-base}}/check-cfg/my-awesome-platform.json -#![feature(lang_items, no_core, auto_traits)] +#![feature(lang_items, no_core, auto_traits, rustc_attrs)] #![no_core] extern crate minicore; use minicore::*; -#[cfg(target_os = "linux")] -fn target_os_linux() {} +#[rustc_builtin_macro] +macro_rules! compile_error { + () => {}; +} -#[cfg(target_os = "ericos")] -fn target_os_ericos() {} +#[cfg(not(target_os = "ericos"))] +compile_error!("target_os from target JSON not wired through"); + +#[cfg(not(target_arch = "tamirdarch"))] +compile_error!("target_arch from target JSON not wired through");