Skip to content

Commit 8d361cb

Browse files
committed
Auto merge of #112374 - chenx97:better-mips64r6, r=jackh726
add mips64r6 and mips32r6 as target_arch values This PR introduces `"mips32r6"` and `"mips64r6"` as valid `target_arch` values, and would be the arch value used by Tier-3 targets `mipsisa32r6-unknown-linux-gnu`, `mipsisa32r6el-unknown-linux-gnu`, `mipsisa64r6-unknown-linux-gnuabi64` and `mipsisa64r6el-unknown-linux-gnuabi64`. This PR was inspired by `rustix` attempting to link traditional mips64el objects with mips64r6el objects when building for mips64r6, even though `rustix` recently removed outline assembly support. This is because currently this target's `target_arch` is `"mips64"` and rustix has its respective assembly implementation as well as a pre-compiled little-endian static library prepared for mips64el, a tier-2 target with the same `target_arch`. After some [discussions on zulip](https://rust-lang.zulipchat.com/#narrow/stream/233931-t-compiler.2Fmajor-changes/topic/Add.20New.20Values.20To.20MIPS_ALLOWED_FEATURES.20compiler-team.23595), I decided to treat mips64r6 as an independent architecture from Rust's POV, since these two architectures are incompatible anyway. This PR is now waiting for `libc` to release a new version with [support](rust-lang/libc#3268) for these `target_arch` values. It is not expected to introduce changes to any other target, especially Tier-1 and Tier-2 targets. This PR has its corresponding [MCP](rust-lang/compiler-team#632) approved.
2 parents f0580df + d372714 commit 8d361cb

File tree

20 files changed

+43
-21
lines changed

20 files changed

+43
-21
lines changed

compiler/rustc_codegen_cranelift/example/float-minmax-pass.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ fn main() {
2222

2323
#[cfg(not(any(target_arch = "mips", target_arch = "mips64")))]
2424
let nan = f32::NAN;
25-
// MIPS hardware treats f32::NAN as SNAN. Clear the signaling bit.
25+
// MIPS hardware except MIPS R6 treats f32::NAN as SNAN. Clear the signaling bit.
2626
// See https://github.com/rust-lang/rust/issues/52746.
2727
#[cfg(any(target_arch = "mips", target_arch = "mips64"))]
2828
let nan = f32::from_bits(f32::NAN.to_bits() - 1);

compiler/rustc_codegen_gcc/example/alloc_system.rs

+2
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,15 @@
1010
#[cfg(any(target_arch = "x86",
1111
target_arch = "arm",
1212
target_arch = "mips",
13+
target_arch = "mips32r6",
1314
target_arch = "powerpc",
1415
target_arch = "powerpc64"))]
1516
const MIN_ALIGN: usize = 8;
1617
#[cfg(any(target_arch = "x86_64",
1718
target_arch = "aarch64",
1819
target_arch = "loongarch64",
1920
target_arch = "mips64",
21+
target_arch = "mips64r6",
2022
target_arch = "s390x",
2123
target_arch = "sparc64"))]
2224
const MIN_ALIGN: usize = 16;

compiler/rustc_codegen_ssa/src/back/metadata.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -193,8 +193,8 @@ pub(crate) fn create_object_file(sess: &Session) -> Option<write::Object<'static
193193
}
194194
"x86" => Architecture::I386,
195195
"s390x" => Architecture::S390x,
196-
"mips" => Architecture::Mips,
197-
"mips64" => Architecture::Mips64,
196+
"mips" | "mips32r6" => Architecture::Mips,
197+
"mips64" | "mips64r6" => Architecture::Mips64,
198198
"x86_64" => {
199199
if sess.target.pointer_width == 32 {
200200
Architecture::X86_64_X32

compiler/rustc_codegen_ssa/src/target_features.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ pub fn supported_target_features(sess: &Session) -> &'static [(&'static str, Opt
321321
"aarch64" => AARCH64_ALLOWED_FEATURES,
322322
"x86" | "x86_64" => X86_ALLOWED_FEATURES,
323323
"hexagon" => HEXAGON_ALLOWED_FEATURES,
324-
"mips" | "mips64" => MIPS_ALLOWED_FEATURES,
324+
"mips" | "mips32r6" | "mips64" | "mips64r6" => MIPS_ALLOWED_FEATURES,
325325
"powerpc" | "powerpc64" => POWERPC_ALLOWED_FEATURES,
326326
"riscv32" | "riscv64" => RISCV_ALLOWED_FEATURES,
327327
"wasm32" | "wasm64" => WASM_ALLOWED_FEATURES,

compiler/rustc_target/src/abi/call/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -693,8 +693,8 @@ impl<'a, Ty> FnAbi<'a, Ty> {
693693
"avr" => avr::compute_abi_info(self),
694694
"loongarch64" => loongarch::compute_abi_info(cx, self),
695695
"m68k" => m68k::compute_abi_info(self),
696-
"mips" => mips::compute_abi_info(cx, self),
697-
"mips64" => mips64::compute_abi_info(cx, self),
696+
"mips" | "mips32r6" => mips::compute_abi_info(cx, self),
697+
"mips64" | "mips64r6" => mips64::compute_abi_info(cx, self),
698698
"powerpc" => powerpc::compute_abi_info(self),
699699
"powerpc64" => powerpc64::compute_abi_info(cx, self),
700700
"s390x" => s390x::compute_abi_info(cx, self),

compiler/rustc_target/src/asm/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -238,8 +238,8 @@ impl FromStr for InlineAsmArch {
238238
"powerpc64" => Ok(Self::PowerPC64),
239239
"hexagon" => Ok(Self::Hexagon),
240240
"loongarch64" => Ok(Self::LoongArch64),
241-
"mips" => Ok(Self::Mips),
242-
"mips64" => Ok(Self::Mips64),
241+
"mips" | "mips32r6" => Ok(Self::Mips),
242+
"mips64" | "mips64r6" => Ok(Self::Mips64),
243243
"s390x" => Ok(Self::S390x),
244244
"spirv" => Ok(Self::SpirV),
245245
"wasm32" => Ok(Self::Wasm32),

compiler/rustc_target/src/spec/mipsisa32r6_unknown_linux_gnu.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ pub fn target() -> Target {
66
llvm_target: "mipsisa32r6-unknown-linux-gnu".into(),
77
pointer_width: 32,
88
data_layout: "E-m:m-p:32:32-i8:8:32-i16:16:32-i64:64-n32-S64".into(),
9-
arch: "mips".into(),
9+
arch: "mips32r6".into(),
1010
options: TargetOptions {
1111
endian: Endian::Big,
1212
cpu: "mips32r6".into(),

compiler/rustc_target/src/spec/mipsisa32r6el_unknown_linux_gnu.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ pub fn target() -> Target {
55
llvm_target: "mipsisa32r6el-unknown-linux-gnu".into(),
66
pointer_width: 32,
77
data_layout: "e-m:m-p:32:32-i8:8:32-i16:16:32-i64:64-n32-S64".into(),
8-
arch: "mips".into(),
8+
arch: "mips32r6".into(),
99

1010
options: TargetOptions {
1111
cpu: "mips32r6".into(),

compiler/rustc_target/src/spec/mipsisa64r6_unknown_linux_gnuabi64.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ pub fn target() -> Target {
66
llvm_target: "mipsisa64r6-unknown-linux-gnuabi64".into(),
77
pointer_width: 64,
88
data_layout: "E-m:e-i8:8:32-i16:16:32-i64:64-n32:64-S128".into(),
9-
arch: "mips64".into(),
9+
arch: "mips64r6".into(),
1010
options: TargetOptions {
1111
abi: "abi64".into(),
1212
endian: Endian::Big,

compiler/rustc_target/src/spec/mipsisa64r6el_unknown_linux_gnuabi64.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ pub fn target() -> Target {
55
llvm_target: "mipsisa64r6el-unknown-linux-gnuabi64".into(),
66
pointer_width: 64,
77
data_layout: "e-m:e-i8:8:32-i16:16:32-i64:64-n32:64-S128".into(),
8-
arch: "mips64".into(),
8+
arch: "mips64r6".into(),
99
options: TargetOptions {
1010
abi: "abi64".into(),
1111
// NOTE(mips64r6) matches C toolchain

library/std/src/os/linux/raw.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ mod arch {
9494
}
9595
}
9696

97-
#[cfg(target_arch = "mips")]
97+
#[cfg(any(target_arch = "mips", target_arch = "mips32r6"))]
9898
mod arch {
9999
use crate::os::raw::{c_long, c_ulong};
100100

@@ -233,6 +233,7 @@ mod arch {
233233
#[cfg(any(
234234
target_arch = "loongarch64",
235235
target_arch = "mips64",
236+
target_arch = "mips64r6",
236237
target_arch = "s390x",
237238
target_arch = "sparc64",
238239
target_arch = "riscv64",

library/std/src/sync/mpmc/utils.rs

+4
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,9 @@ use crate::ops::{Deref, DerefMut};
3535
any(
3636
target_arch = "arm",
3737
target_arch = "mips",
38+
target_arch = "mips32r6",
3839
target_arch = "mips64",
40+
target_arch = "mips64r6",
3941
target_arch = "riscv64",
4042
),
4143
repr(align(32))
@@ -59,7 +61,9 @@ use crate::ops::{Deref, DerefMut};
5961
target_arch = "powerpc64",
6062
target_arch = "arm",
6163
target_arch = "mips",
64+
target_arch = "mips32r6",
6265
target_arch = "mips64",
66+
target_arch = "mips64r6",
6367
target_arch = "riscv64",
6468
target_arch = "s390x",
6569
)),

library/std/src/sys/common/alloc.rs

+2
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ use crate::ptr;
99
target_arch = "arm",
1010
target_arch = "m68k",
1111
target_arch = "mips",
12+
target_arch = "mips32r6",
1213
target_arch = "powerpc",
1314
target_arch = "powerpc64",
1415
target_arch = "sparc",
@@ -24,6 +25,7 @@ pub const MIN_ALIGN: usize = 8;
2425
target_arch = "aarch64",
2526
target_arch = "loongarch64",
2627
target_arch = "mips64",
28+
target_arch = "mips64r6",
2729
target_arch = "s390x",
2830
target_arch = "sparc64",
2931
target_arch = "riscv64",

library/std/src/sys/personality/gcc.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,12 @@ const UNWIND_DATA_REG: (i32, i32) = (0, 1); // R0, R1 / X0, X1
5959
#[cfg(target_arch = "m68k")]
6060
const UNWIND_DATA_REG: (i32, i32) = (0, 1); // D0, D1
6161

62-
#[cfg(any(target_arch = "mips", target_arch = "mips64"))]
62+
#[cfg(any(
63+
target_arch = "mips",
64+
target_arch = "mips32r6",
65+
target_arch = "mips64",
66+
target_arch = "mips64r6"
67+
))]
6368
const UNWIND_DATA_REG: (i32, i32) = (4, 5); // A0, A1
6469

6570
#[cfg(any(target_arch = "powerpc", target_arch = "powerpc64"))]

library/unwind/src/libunwind.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,10 @@ pub const unwinder_private_data_size: usize = 5;
5151
#[cfg(target_arch = "m68k")]
5252
pub const unwinder_private_data_size: usize = 2;
5353

54-
#[cfg(target_arch = "mips")]
54+
#[cfg(any(target_arch = "mips", target_arch = "mips32r6"))]
5555
pub const unwinder_private_data_size: usize = 2;
5656

57-
#[cfg(target_arch = "mips64")]
57+
#[cfg(any(target_arch = "mips64", target_arch = "mips64r6"))]
5858
pub const unwinder_private_data_size: usize = 2;
5959

6060
#[cfg(any(target_arch = "powerpc", target_arch = "powerpc64"))]

src/bootstrap/lib.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,12 @@ const EXTRA_CHECK_CFGS: &[(Option<Mode>, &'static str, Option<&[&'static str]>)]
133133
/* Extra values not defined in the built-in targets yet, but used in std */
134134
(Some(Mode::Std), "target_env", Some(&["libnx"])),
135135
// (Some(Mode::Std), "target_os", Some(&[])),
136-
(Some(Mode::Std), "target_arch", Some(&["asmjs", "spirv", "nvptx", "xtensa"])),
136+
// #[cfg(bootstrap)] mips32r6, mips64r6
137+
(
138+
Some(Mode::Std),
139+
"target_arch",
140+
Some(&["asmjs", "spirv", "nvptx", "xtensa", "mips32r6", "mips64r6"]),
141+
),
137142
/* Extra names used by dependencies */
138143
// FIXME: Used by serde_json, but we should not be triggering on external dependencies.
139144
(Some(Mode::Rustc), "no_btreemap_remove_entry", None),

src/librustdoc/clean/cfg.rs

+2
Original file line numberDiff line numberDiff line change
@@ -520,7 +520,9 @@ impl<'a> fmt::Display for Display<'a> {
520520
"loongarch64" => "LoongArch LA64",
521521
"m68k" => "M68k",
522522
"mips" => "MIPS",
523+
"mips32r6" => "MIPS Release 6",
523524
"mips64" => "MIPS-64",
525+
"mips64r6" => "MIPS-64 Release 6",
524526
"msp430" => "MSP430",
525527
"powerpc" => "PowerPC",
526528
"powerpc64" => "PowerPC-64",

src/tools/miri/src/shims/foreign_items.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,9 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
4545
// List taken from `library/std/src/sys/common/alloc.rs`.
4646
// This list should be kept in sync with the one from libstd.
4747
let min_align = match this.tcx.sess.target.arch.as_ref() {
48-
"x86" | "arm" | "mips" | "powerpc" | "powerpc64" | "asmjs" | "wasm32" => 8,
49-
"x86_64" | "aarch64" | "mips64" | "s390x" | "sparc64" | "loongarch64" => 16,
48+
"x86" | "arm" | "mips" | "mips32r6" | "powerpc" | "powerpc64" | "asmjs" | "wasm32" => 8,
49+
"x86_64" | "aarch64" | "mips64" | "mips64r6" | "s390x" | "sparc64" | "loongarch64" =>
50+
16,
5051
arch => bug!("unsupported target architecture for malloc: `{}`", arch),
5152
};
5253
// Windows always aligns, even small allocations.

tests/ui/check-cfg/compact-values.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ warning: unexpected `cfg` condition value
44
LL | #[cfg(target(os = "linux", arch = "X"))]
55
| ^^^^^^^^^^
66
|
7-
= note: expected values for `target_arch` are: `aarch64`, `arm`, `avr`, `bpf`, `hexagon`, `loongarch64`, `m68k`, `mips`, `mips64`, `msp430`, `nvptx64`, `powerpc`, `powerpc64`, `riscv32`, `riscv64`, `s390x`, `sparc`, `sparc64`, `wasm32`, `wasm64`, `x86`, `x86_64`
7+
= note: expected values for `target_arch` are: `aarch64`, `arm`, `avr`, `bpf`, `hexagon`, `loongarch64`, `m68k`, `mips`, `mips32r6`, `mips64`, `mips64r6`, `msp430`, `nvptx64`, `powerpc`, `powerpc64`, `riscv32`, `riscv64`, `s390x`, `sparc`, `sparc64`, `wasm32`, `wasm64`, `x86`, `x86_64`
88
= note: `#[warn(unexpected_cfgs)]` on by default
99

1010
warning: 1 warning emitted

tests/ui/simd/intrinsic/float-minmax-pass.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ fn main() {
2121

2222
#[cfg(not(any(target_arch = "mips", target_arch = "mips64")))]
2323
let nan = f32::NAN;
24-
// MIPS hardware treats f32::NAN as SNAN. Clear the signaling bit.
24+
// MIPS hardware except MIPS R6 treats f32::NAN as SNAN. Clear the signaling bit.
2525
// See https://github.com/rust-lang/rust/issues/52746.
2626
#[cfg(any(target_arch = "mips", target_arch = "mips64"))]
2727
let nan = f32::from_bits(f32::NAN.to_bits() - 1);

0 commit comments

Comments
 (0)