Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions compiler/rustc_span/src/symbol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1950,6 +1950,7 @@ symbols! {
sparc,
sparc64,
sparc_target_feature,
spe,
spe_acc,
specialization,
speed,
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_target/src/asm/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use rustc_data_structures::fx::{FxHashMap, FxIndexSet};
use rustc_macros::{Decodable, Encodable, StableHash};
use rustc_span::Symbol;

use crate::spec::{Arch, CfgAbi, RelocModel, Target};
use crate::spec::{Arch, RelocModel, Target};

pub struct ModifierInfo {
pub modifier: char,
Expand Down Expand Up @@ -1001,7 +1001,7 @@ impl InlineAsmClobberAbi {
_ => Err(&["C", "system", "efiapi"]),
},
InlineAsmArch::PowerPC | InlineAsmArch::PowerPC64 => match name {
"C" | "system" => Ok(if target.cfg_abi == CfgAbi::Spe {
"C" | "system" => Ok(if powerpc::is_spe(target_features) {
InlineAsmClobberAbi::PowerPCSPE
} else {
InlineAsmClobberAbi::PowerPC
Expand Down
16 changes: 8 additions & 8 deletions compiler/rustc_target/src/asm/powerpc.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::fmt;

use rustc_data_structures::fx::FxIndexSet;
use rustc_span::Symbol;
use rustc_span::{Symbol, sym};

use super::{InlineAsmArch, InlineAsmType, ModifierInfo};
use crate::spec::{CfgAbi, RelocModel, Target};
Expand Down Expand Up @@ -115,18 +115,18 @@ fn reserved_v20to31(
}
}

pub(crate) fn is_spe(target_features: &FxIndexSet<Symbol>) -> bool {
target_features.contains(&sym::spe)
}
Copy link
Copy Markdown
Member

@RalfJung RalfJung May 30, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, we can't do this. Target features are not guaranteed to be consistent across the crate graph. Also we shouldn't parse the target feature like this. Instead, we have the target unambiguously indicate the ABI and then we force the target features to match.

I am working on extending #157085 with SPE support.

Copy link
Copy Markdown
Member

@RalfJung RalfJung May 30, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here's a patch that extends our existing ABI tracking to also cover SPE:
751237abda7


fn spe_acc_target_check(
_arch: InlineAsmArch,
_reloc_model: RelocModel,
_target_features: &FxIndexSet<Symbol>,
target: &Target,
target_features: &FxIndexSet<Symbol>,
_target: &Target,
_is_clobber: bool,
) -> Result<(), &'static str> {
if target.cfg_abi == CfgAbi::Spe {
Ok(())
} else {
Err("spe_acc is only available on spe targets")
}
if is_spe(target_features) { Ok(()) } else { Err("spe_acc is only available on spe targets") }
}

def_regs! {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ pub(crate) fn target() -> Target {
options: TargetOptions {
cfg_abi: CfgAbi::Spe,
endian: Endian::Big,
features: "+secure-plt,+msync".into(),
features: "+secure-plt,+msync,+spe".into(),
mcount: "_mcount".into(),
..base
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ pub(crate) fn target() -> Target {
options: TargetOptions {
cfg_abi: CfgAbi::Spe,
endian: Endian::Big,
features: "+msync".into(),
features: "+msync,+spe".into(),
mcount: "_mcount".into(),
..base
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ pub(crate) fn target() -> Target {
cfg_abi: CfgAbi::Spe,
endian: Endian::Big,
// feature msync would disable instruction 'fsync' which is not supported by fsl_p1p2
features: "+secure-plt,+msync".into(),
features: "+secure-plt,+msync,+spe".into(),
..base
},
}
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_target/src/target_features.rs
Original file line number Diff line number Diff line change
Expand Up @@ -581,6 +581,7 @@ static POWERPC_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
("power9-vector", Unstable(sym::powerpc_target_feature), &["power8-vector", "power9-altivec"]),
("power10-vector", Unstable(sym::powerpc_target_feature), &["power9-vector"]),
("quadword-atomics", Unstable(sym::powerpc_target_feature), &[]),
("spe", Forbidden { reason: "use a powerpcspe target instead", hard_error: false }, &[]),
("vsx", Unstable(sym::powerpc_target_feature), &["altivec"]),
// tidy-alphabetical-end
];
Expand Down
Loading