Skip to content

make mips64 Complex GCC-compatible - #162921

Merged
rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
folkertdev:complex-mips64
Oct 1, 2026
Merged

rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
folkertdev:complex-mips64

Conversation

@folkertdev

Copy link
Copy Markdown
Contributor

tracking issue: #154023

This implementation is compatible with GCC and Clang >= 24, see llvm/llvm-project#212109.

This implementation has been validated versus GCC and Clang 24 with abi-cafe.

@folkertdev folkertdev added the F-complex_numbers `#![feature(complex_numbers)]` label Sep 17, 2026
@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 Sep 17, 2026
@rust-bors

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@folkertdev

Copy link
Copy Markdown
Contributor Author

r? beetrees

(one of 3 remaining architectures: we're getting there!)

@rustbot

rustbot commented Sep 25, 2026

Copy link
Copy Markdown
Collaborator

beetrees is currently at their maximum review capacity.
They may take a while to respond.

@folkertdev
folkertdev marked this pull request as ready for review September 25, 2026 11:39
@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 Sep 25, 2026

@beetrees beetrees left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I've verified against GCC's current behaviour.

View changes since this review

arg.cast_to_and_pad_i32(Uniform::new(Reg::i64(), size), pad_i32);
}
Numeric::Float(Float::F128) => {
// Complex<f128> is passed in 4 GPRs, but aligned to 16 so may need padding.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
// Complex<f128> is passed in 4 GPRs, but aligned to 16 so may need padding.
// Complex<f128> is passed in 4 FPRs, but aligned to 16 so may need padding.

arg.cast_to(cast_target.with_attrs(ArgAttribute::InReg.into()));
}
Numeric::Int(Integer::I64 | Integer::I128, _) => {
// Complex<i64> and Complex<i64> are passed as 2 separate arguments, which is what

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
// Complex<i64> and Complex<i64> are passed as 2 separate arguments, which is what
// Complex<i64> and Complex<i128> are passed as 2 separate arguments, which is what

Numeric::Float(Float::F32 | Float::F64) => {
// Only pass a Complex<f32>/Complex<f64> in FPRs when two argument slots are free,
if curr_offset.bytes() / slot.bytes() + 2 <= NUM_ARG_SLOTS {
// The default `PassMode::Pair` already passes one component per register. Both

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can we use PassMode::Cast rather than relying on PassMode::Pair happening to do the right thing?

}
Numeric::Int(Integer::I64 | Integer::I128, _) => {
// Complex<i64> and Complex<i64> are passed as 2 separate arguments, which is what
// the default `PassMode::Pair` already does.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Use PassMode::Cast here too?

Numeric::Float(Float::F16) => unreachable!("not supported on mips64"),
Numeric::Float(Float::F32 | Float::F64) => {
// Only pass a Complex<f32>/Complex<f64> in FPRs when two argument slots are free,
if curr_offset.bytes() / slot.bytes() + 2 <= NUM_ARG_SLOTS {

@beetrees beetrees Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

C-variadic arguments are always passed in GPRs, so Complex<f32> needs to be passed in one slot in that case.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

If you're wanting to leave C-variadic compatibility till later, leave a FIXME here instead?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Add a test for passing Complex as a C-variadic argument?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Our va_arg can't handle that for most targets at the moment (and VaArgSafe is not implemented for Complex yet). I intend to do another sweep for c-variadic once we have "normal" call support across targets.

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Sep 30, 2026
@rustbot

rustbot commented Sep 30, 2026

Copy link
Copy Markdown
Collaborator

Reminder, once the PR becomes ready for a review, use @rustbot ready.

@rustbot

rustbot commented Sep 30, 2026

Copy link
Copy Markdown
Collaborator

This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

@folkertdev

Copy link
Copy Markdown
Contributor Author

@rustbot ready

@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 Sep 30, 2026

@beetrees beetrees left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

r=me once FIXME has been added.

View changes since this review

Numeric::Float(Float::F16) => unreachable!("not supported on mips64"),
Numeric::Float(Float::F32 | Float::F64) => {
// Only pass a Complex<f32>/Complex<f64> in FPRs when two argument slots are free,
if curr_offset.bytes() / slot.bytes() + 2 <= NUM_ARG_SLOTS {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

If you're wanting to leave C-variadic compatibility till later, leave a FIXME here instead?

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Sep 30, 2026
@folkertdev

Copy link
Copy Markdown
Contributor Author

fixme added (I assume we can just treat all complex numbers generically for it, but we'll see)

@bors r=beetrees rollup

@rust-bors

rust-bors Bot commented Sep 30, 2026

Copy link
Copy Markdown
Contributor

📌 Commit dd0f941 has been tentatively approved by beetrees

It will be put into the queue for this repository once PR CI succeeds.

@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-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Sep 30, 2026
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Sep 30, 2026
make mips64 `Complex` GCC-compatible

tracking issue: rust-lang#154023

This implementation is compatible with GCC and Clang >= 24, see llvm/llvm-project#212109.

This implementation has been validated versus GCC and Clang 24 with abi-cafe.
rust-bors Bot pushed a commit that referenced this pull request Sep 30, 2026
…uwer

Rollup of 18 pull requests

Successful merges:

 - #163532 (rustc_codegen_cranelift subtree update)
 - #163534 (miri subtree update)
 - #163279 (const and NonZero impl for clamp_magnitude())
 - #162900 (Some refactorings around metadata encoding)
 - #163455 (Don't use the metadata based crate_hash for rustdoc runs)
 - #159798 (Attribute documentation for cfg_attr)
 - #162921 (make mips64 `Complex` GCC-compatible)
 - #163368 (Don't build format string suggestions from `concat!` offsets)
 - #163375 (Update expect messages in library/std/src/os/unix/net/ following Rust's `expect` guidance)
 - #163405 (Remove some #[linkage] options)
 - #163470 (Miscellaneous attr error stuff)
 - #163489 (expose Rc::is_unique)
 - #163492 (x86 and x86_64: cleanup some callconv code)
 - #163496 (cycle handling: mirror old solver)
 - #163509 (Use more default field values in `Resolver`)
 - #163519 (Forbid  `Reborrow` impls for types with destructors)
 - #163520 (Cast cleanups)
 - #163524 (Document `Result` case for the `arena_cache` query modifier)
rust-bors Bot pushed a commit that referenced this pull request Sep 30, 2026
…uwer

Rollup of 18 pull requests

Successful merges:

 - #163532 (rustc_codegen_cranelift subtree update)
 - #163534 (miri subtree update)
 - #163279 (const and NonZero impl for clamp_magnitude())
 - #162900 (Some refactorings around metadata encoding)
 - #163455 (Don't use the metadata based crate_hash for rustdoc runs)
 - #159798 (Attribute documentation for cfg_attr)
 - #162921 (make mips64 `Complex` GCC-compatible)
 - #163368 (Don't build format string suggestions from `concat!` offsets)
 - #163375 (Update expect messages in library/std/src/os/unix/net/ following Rust's `expect` guidance)
 - #163405 (Remove some #[linkage] options)
 - #163470 (Miscellaneous attr error stuff)
 - #163489 (expose Rc::is_unique)
 - #163492 (x86 and x86_64: cleanup some callconv code)
 - #163496 (cycle handling: mirror old solver)
 - #163509 (Use more default field values in `Resolver`)
 - #163519 (Forbid  `Reborrow` impls for types with destructors)
 - #163520 (Cast cleanups)
 - #163524 (Document `Result` case for the `arena_cache` query modifier)
rust-bors Bot pushed a commit that referenced this pull request Oct 1, 2026
Rollup of 20 pull requests

Successful merges:

 - #163279 (const and NonZero impl for clamp_magnitude())
 - #163081 (Provide more context on "not general enough" error)
 - #163455 (Don't use the metadata based crate_hash for rustdoc runs)
 - #159798 (Attribute documentation for cfg_attr)
 - #162921 (make mips64 `Complex` GCC-compatible)
 - #163368 (Don't build format string suggestions from `concat!` offsets)
 - #163375 (Update expect messages in library/std/src/os/unix/net/ following Rust's `expect` guidance)
 - #163470 (Miscellaneous attr error stuff)
 - #163489 (expose Rc::is_unique)
 - #163492 (x86 and x86_64: cleanup some callconv code)
 - #163496 (cycle handling: mirror old solver)
 - #163509 (Use more default field values in `Resolver`)
 - #163519 (Forbid  `Reborrow` impls for types with destructors)
 - #163520 (Cast cleanups)
 - #163524 (Document `Result` case for the `arena_cache` query modifier)
 - #163546 (PassWrapper: adapt for new PassPlugin load method)
 - #163551 (Add libs-nominated triagebot config)
 - #163559 (Suggest `#[unsafe(no_mangle)]` for entry points in `no_std` binaries)
 - #163564 (rustc-dev-guide subtree update)
 - #163568 (remove dead cfg_select! arm)
@rust-bors
rust-bors Bot merged commit 973d397 into rust-lang:main Oct 1, 2026
13 checks passed
@rustbot rustbot added this to the 1.101.0 milestone Oct 1, 2026
rust-bors Bot pushed a commit that referenced this pull request Oct 1, 2026
Rollup merge of #162921 - folkertdev:complex-mips64, r=beetrees

make mips64 `Complex` GCC-compatible

tracking issue: #154023

This implementation is compatible with GCC and Clang >= 24, see llvm/llvm-project#212109.

This implementation has been validated versus GCC and Clang 24 with abi-cafe.
RalfJung pushed a commit to RalfJung/miri that referenced this pull request Oct 1, 2026
Rollup of 20 pull requests

Successful merges:

 - rust-lang/rust#163279 (const and NonZero impl for clamp_magnitude())
 - rust-lang/rust#163081 (Provide more context on "not general enough" error)
 - rust-lang/rust#163455 (Don't use the metadata based crate_hash for rustdoc runs)
 - rust-lang/rust#159798 (Attribute documentation for cfg_attr)
 - rust-lang/rust#162921 (make mips64 `Complex` GCC-compatible)
 - rust-lang/rust#163368 (Don't build format string suggestions from `concat!` offsets)
 - rust-lang/rust#163375 (Update expect messages in library/std/src/os/unix/net/ following Rust's `expect` guidance)
 - rust-lang/rust#163470 (Miscellaneous attr error stuff)
 - rust-lang/rust#163489 (expose Rc::is_unique)
 - rust-lang/rust#163492 (x86 and x86_64: cleanup some callconv code)
 - rust-lang/rust#163496 (cycle handling: mirror old solver)
 - rust-lang/rust#163509 (Use more default field values in `Resolver`)
 - rust-lang/rust#163519 (Forbid  `Reborrow` impls for types with destructors)
 - rust-lang/rust#163520 (Cast cleanups)
 - rust-lang/rust#163524 (Document `Result` case for the `arena_cache` query modifier)
 - rust-lang/rust#163546 (PassWrapper: adapt for new PassPlugin load method)
 - rust-lang/rust#163551 (Add libs-nominated triagebot config)
 - rust-lang/rust#163559 (Suggest `#[unsafe(no_mangle)]` for entry points in `no_std` binaries)
 - rust-lang/rust#163564 (rustc-dev-guide subtree update)
 - rust-lang/rust#163568 (remove dead cfg_select! arm)
github-actions Bot pushed a commit to rust-lang/rustc-dev-guide that referenced this pull request Oct 5, 2026
Rollup of 20 pull requests

Successful merges:

 - rust-lang/rust#163279 (const and NonZero impl for clamp_magnitude())
 - rust-lang/rust#163081 (Provide more context on "not general enough" error)
 - rust-lang/rust#163455 (Don't use the metadata based crate_hash for rustdoc runs)
 - rust-lang/rust#159798 (Attribute documentation for cfg_attr)
 - rust-lang/rust#162921 (make mips64 `Complex` GCC-compatible)
 - rust-lang/rust#163368 (Don't build format string suggestions from `concat!` offsets)
 - rust-lang/rust#163375 (Update expect messages in library/std/src/os/unix/net/ following Rust's `expect` guidance)
 - rust-lang/rust#163470 (Miscellaneous attr error stuff)
 - rust-lang/rust#163489 (expose Rc::is_unique)
 - rust-lang/rust#163492 (x86 and x86_64: cleanup some callconv code)
 - rust-lang/rust#163496 (cycle handling: mirror old solver)
 - rust-lang/rust#163509 (Use more default field values in `Resolver`)
 - rust-lang/rust#163519 (Forbid  `Reborrow` impls for types with destructors)
 - rust-lang/rust#163520 (Cast cleanups)
 - rust-lang/rust#163524 (Document `Result` case for the `arena_cache` query modifier)
 - rust-lang/rust#163546 (PassWrapper: adapt for new PassPlugin load method)
 - rust-lang/rust#163551 (Add libs-nominated triagebot config)
 - rust-lang/rust#163559 (Suggest `#[unsafe(no_mangle)]` for entry points in `no_std` binaries)
 - rust-lang/rust#163564 (rustc-dev-guide subtree update)
 - rust-lang/rust#163568 (remove dead cfg_select! arm)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

F-complex_numbers `#![feature(complex_numbers)]` 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.

4 participants