diff options
Diffstat (limited to 'compiler')
| -rw-r--r-- | compiler/rustc_codegen_llvm/src/llvm_util.rs | 11 | ||||
| -rw-r--r-- | compiler/rustc_codegen_ssa/src/back/metadata.rs | 2 | ||||
| -rw-r--r-- | compiler/rustc_feature/src/unstable.rs | 1 | ||||
| -rw-r--r-- | compiler/rustc_span/src/symbol.rs | 2 | ||||
| -rw-r--r-- | compiler/rustc_target/src/spec/targets/sparc_unknown_linux_gnu.rs | 1 | ||||
| -rw-r--r-- | compiler/rustc_target/src/target_features.rs | 10 |
6 files changed, 26 insertions, 1 deletions
diff --git a/compiler/rustc_codegen_llvm/src/llvm_util.rs b/compiler/rustc_codegen_llvm/src/llvm_util.rs index 6f2d86cc601..c382242d8d0 100644 --- a/compiler/rustc_codegen_llvm/src/llvm_util.rs +++ b/compiler/rustc_codegen_llvm/src/llvm_util.rs @@ -228,6 +228,8 @@ pub(crate) fn to_llvm_features<'a>(sess: &Session, s: &'a str) -> Option<LLVMFea "x86" } else if sess.target.arch == "arm64ec" { "aarch64" + } else if sess.target.arch == "sparc64" { + "sparc" } else { &*sess.target.arch }; @@ -280,6 +282,13 @@ pub(crate) fn to_llvm_features<'a>(sess: &Session, s: &'a str) -> Option<LLVMFea // Support for `wide-arithmetic` will first land in LLVM 20 as part of // llvm/llvm-project#111598 ("wasm32" | "wasm64", "wide-arithmetic") if get_version() < (20, 0, 0) => None, + ("sparc", "leoncasa") => Some(LLVMFeature::new("hasleoncasa")), + // In LLVM 19, there is no `v8plus` feature and `v9` means "SPARC-V9 instruction available and SPARC-V8+ ABI used". + // https://github.com/llvm/llvm-project/blob/llvmorg-19.1.0/llvm/lib/Target/Sparc/MCTargetDesc/SparcELFObjectWriter.cpp#L27-L28 + // Before LLVM 19, there is no `v8plus` feature and `v9` means "SPARC-V9 instruction available". + // https://github.com/llvm/llvm-project/blob/llvmorg-18.1.0/llvm/lib/Target/Sparc/MCTargetDesc/SparcELFObjectWriter.cpp#L26 + ("sparc", "v8plus") if get_version().0 == 19 => Some(LLVMFeature::new("v9")), + ("sparc", "v8plus") if get_version().0 < 19 => None, (_, s) => Some(LLVMFeature::new(s)), } } @@ -619,6 +628,8 @@ pub(crate) fn global_llvm_features( .features .split(',') .filter(|v| !v.is_empty() && backend_feature_name(sess, v).is_some()) + // Drop +v8plus feature introduced in LLVM 20. + .filter(|v| *v != "+v8plus" || get_version() >= (20, 0, 0)) .map(String::from), ); diff --git a/compiler/rustc_codegen_ssa/src/back/metadata.rs b/compiler/rustc_codegen_ssa/src/back/metadata.rs index 3f3cb8b4073..bdf7030f946 100644 --- a/compiler/rustc_codegen_ssa/src/back/metadata.rs +++ b/compiler/rustc_codegen_ssa/src/back/metadata.rs @@ -212,7 +212,7 @@ pub(crate) fn create_object_file(sess: &Session) -> Option<write::Object<'static "riscv32" => (Architecture::Riscv32, None), "riscv64" => (Architecture::Riscv64, None), "sparc" => { - if sess.target.options.cpu == "v9" { + if sess.unstable_target_features.contains(&sym::v8plus) { // Target uses V8+, aka EM_SPARC32PLUS, aka 64-bit V9 but in 32-bit mode (Architecture::Sparc32Plus, None) } else { diff --git a/compiler/rustc_feature/src/unstable.rs b/compiler/rustc_feature/src/unstable.rs index 5f83c211b38..8326d0031ea 100644 --- a/compiler/rustc_feature/src/unstable.rs +++ b/compiler/rustc_feature/src/unstable.rs @@ -336,6 +336,7 @@ declare_features! ( (unstable, riscv_target_feature, "1.45.0", Some(44839)), (unstable, rtm_target_feature, "1.35.0", Some(44839)), (unstable, s390x_target_feature, "1.82.0", Some(44839)), + (unstable, sparc_target_feature, "CURRENT_RUSTC_VERSION", Some(132783)), (unstable, sse4a_target_feature, "1.27.0", Some(44839)), (unstable, tbm_target_feature, "1.27.0", Some(44839)), (unstable, wasm_target_feature, "1.30.0", Some(44839)), diff --git a/compiler/rustc_span/src/symbol.rs b/compiler/rustc_span/src/symbol.rs index 82cfbd28fff..c04c793ba46 100644 --- a/compiler/rustc_span/src/symbol.rs +++ b/compiler/rustc_span/src/symbol.rs @@ -1867,6 +1867,7 @@ symbols! { slice_patterns, slicing_syntax, soft, + sparc_target_feature, specialization, speed, spotlight, @@ -2109,6 +2110,7 @@ symbols! { usize_legacy_fn_max_value, usize_legacy_fn_min_value, usize_legacy_mod, + v8plus, va_arg, va_copy, va_end, 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 2777395757f..45941cd7c01 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 @@ -14,6 +14,7 @@ pub(crate) fn target() -> Target { data_layout: "E-m:e-p:32:32-i64:64-i128:128-f128:64-n32-S64".into(), arch: "sparc".into(), options: TargetOptions { + features: "+v8plus".into(), cpu: "v9".into(), endian: Endian::Big, late_link_args: TargetOptions::link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &[ diff --git a/compiler/rustc_target/src/target_features.rs b/compiler/rustc_target/src/target_features.rs index 96f1e257bb5..dc5de413e4b 100644 --- a/compiler/rustc_target/src/target_features.rs +++ b/compiler/rustc_target/src/target_features.rs @@ -545,6 +545,14 @@ const IBMZ_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[ // tidy-alphabetical-end ]; +const SPARC_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[ + // tidy-alphabetical-start + ("leoncasa", Unstable(sym::sparc_target_feature), &[]), + ("v8plus", Unstable(sym::sparc_target_feature), &[]), + ("v9", Unstable(sym::sparc_target_feature), &[]), + // tidy-alphabetical-end +]; + /// When rustdoc is running, provide a list of all known features so that all their respective /// primitives may be documented. /// @@ -563,6 +571,7 @@ pub fn all_rust_features() -> impl Iterator<Item = (&'static str, Stability)> { .chain(CSKY_FEATURES) .chain(LOONGARCH_FEATURES) .chain(IBMZ_FEATURES) + .chain(SPARC_FEATURES) .cloned() .map(|(f, s, _)| (f, s)) } @@ -582,6 +591,7 @@ impl super::spec::Target { "csky" => CSKY_FEATURES, "loongarch64" => LOONGARCH_FEATURES, "s390x" => IBMZ_FEATURES, + "sparc" | "sparc64" => SPARC_FEATURES, _ => &[], } } |
