Skip to content

Commit 7ff0bb8

Browse files
Rollup merge of #157140 - taiki-e:powerpcspe-asm, r=RalfJung
rustc_target: Use rustc_abi instead of cfg_abi to detect powerpcspe When self-reviewing #157137, I recalled a previous my comment (#153876 (comment)) about a case where cfg_abi is referred but rustc_abi should be referred. > There is another powerpc code that [refers to `abi` field](https://github.com/rust-lang/rust/blob/bfc05d6b072585dfd0c792ec1b8728c08a3511fe/compiler/rustc_target/src/asm/powerpc.rs#L125), but it should be changed to refer to the target feature. `tests/codegen-llvm/asm/powerpc-clobbers.rs` contains a test to check whether this detection is working properly: https://github.com/rust-lang/rust/blob/6368fd52cb9f230dfb156097625993e7a8891800/tests/codegen-llvm/asm/powerpc-clobbers.rs#L123 r? @RalfJung @rustbot label +O-PowerPC +A-target-feature
2 parents 3503a9c + d4e6f26 commit 7ff0bb8

2 files changed

Lines changed: 8 additions & 8 deletions

File tree

compiler/rustc_target/src/asm/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use rustc_data_structures::fx::{FxHashMap, FxIndexSet};
55
use rustc_macros::{Decodable, Encodable, StableHash};
66
use rustc_span::Symbol;
77

8-
use crate::spec::{Arch, CfgAbi, RelocModel, Target};
8+
use crate::spec::{Arch, RelocModel, Target};
99

1010
pub struct ModifierInfo {
1111
pub modifier: char,
@@ -1001,7 +1001,7 @@ impl InlineAsmClobberAbi {
10011001
_ => Err(&["C", "system", "efiapi"]),
10021002
},
10031003
InlineAsmArch::PowerPC | InlineAsmArch::PowerPC64 => match name {
1004-
"C" | "system" => Ok(if target.cfg_abi == CfgAbi::Spe {
1004+
"C" | "system" => Ok(if powerpc::is_spe(target) {
10051005
InlineAsmClobberAbi::PowerPCSPE
10061006
} else {
10071007
InlineAsmClobberAbi::PowerPC

compiler/rustc_target/src/asm/powerpc.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use rustc_data_structures::fx::FxIndexSet;
44
use rustc_span::Symbol;
55

66
use super::{InlineAsmArch, InlineAsmType, ModifierInfo};
7-
use crate::spec::{CfgAbi, RelocModel, Target};
7+
use crate::spec::{CfgAbi, RelocModel, RustcAbi, Target};
88

99
def_reg_class! {
1010
PowerPC PowerPCInlineAsmRegClass {
@@ -115,18 +115,18 @@ fn reserved_v20to31(
115115
}
116116
}
117117

118+
pub(crate) fn is_spe(target: &Target) -> bool {
119+
target.rustc_abi == Some(RustcAbi::PowerPcSpe)
120+
}
121+
118122
fn spe_acc_target_check(
119123
_arch: InlineAsmArch,
120124
_reloc_model: RelocModel,
121125
_target_features: &FxIndexSet<Symbol>,
122126
target: &Target,
123127
_is_clobber: bool,
124128
) -> Result<(), &'static str> {
125-
if target.cfg_abi == CfgAbi::Spe {
126-
Ok(())
127-
} else {
128-
Err("spe_acc is only available on spe targets")
129-
}
129+
if is_spe(target) { Ok(()) } else { Err("spe_acc is only available on spe targets") }
130130
}
131131

132132
def_regs! {

0 commit comments

Comments
 (0)