Skip to content

rustc_target: Use rustc_abi instead of cfg_abi to detect powerpcspe #157140

Open
taiki-e wants to merge 1 commit into
rust-lang:mainfrom
taiki-e:powerpcspe-asm
Open

rustc_target: Use rustc_abi instead of cfg_abi to detect powerpcspe #157140
taiki-e wants to merge 1 commit into
rust-lang:mainfrom
taiki-e:powerpcspe-asm

Conversation

@taiki-e
Copy link
Copy Markdown
Member

@taiki-e taiki-e commented May 30, 2026

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, 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:

// powerpcspe: asm sideeffect "nop", "={r0},={r3},={r4},={r5},={r6},={r7},={r8},={r9},={r10},={r11},={r12},~{cr0},~{cr1},~{cr5},~{cr6},~{cr7},~{ctr},~{lr},~{xer},~{spe_acc}"()

r? @RalfJung

@rustbot label +O-PowerPC +A-target-feature

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels May 30, 2026
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented May 30, 2026

RalfJung is not on the review rotation at the moment.
They may take a while to respond.

@rustbot rustbot added A-target-feature Area: Enabling/disabling target features like AVX, Neon, etc. O-PowerPC Target: PowerPC processors labels May 30, 2026

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

@rust-bors

This comment has been minimized.

@taiki-e taiki-e changed the title rustc_target: Use target_feature instead of cfg_abi to detect powerpcspe rustc_target: Use rustc_abi instead of cfg_abi to detect powerpcspe Jun 4, 2026
@taiki-e
Copy link
Copy Markdown
Member Author

taiki-e commented Jun 4, 2026

Updated to refer rustc_abi.

@taiki-e taiki-e marked this pull request as ready for review June 4, 2026 16:10
@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jun 4, 2026
@RalfJung
Copy link
Copy Markdown
Member

RalfJung commented Jun 4, 2026

@bors r+ rollup

Nice, removing more cfg_abi usage in the compiler is always a good sign.

@rust-bors
Copy link
Copy Markdown
Contributor

rust-bors Bot commented Jun 4, 2026

📌 Commit d4e6f26 has been approved by RalfJung

It is now in the queue for this repository.

@rust-bors rust-bors Bot added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jun 4, 2026
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Jun 4, 2026
 rustc_target: Use rustc_abi instead of cfg_abi to detect powerpcspe

When self-reviewing rust-lang#157137, I recalled a previous my comment (rust-lang#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
rust-bors Bot pushed a commit that referenced this pull request Jun 4, 2026
…uwer

Rollup of 8 pull requests

Successful merges:

 - #156281 (Emit nofree attribute)
 - #157305 (Eagerly decide whether relaxed bounds are allowed or not)
 - #148713 (rustc_borrowck: fix async closure error note to report AsyncFn rather than Fn)
 - #156266 (Don't ICE in has_self_borrows when coroutine captures-by-ref ty is still inferred)
 - #156417 (Fix an ICE in the vtable iteration for a trait reference in const eval when a supertrait is not implemented)
 - #156956 (Support generic params in `Lift_Generic`)
 - #157140 ( rustc_target: Use rustc_abi instead of cfg_abi to detect powerpcspe )
 - #157423 (Refactor/expand rustc_attr_parsing docs)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-target-feature Area: Enabling/disabling target features like AVX, Neon, etc. O-PowerPC Target: PowerPC processors S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants