Skip to content

Conversation

@androm3da
Copy link
Contributor

Previously, rustc rejected HvxVectorPair types in function signatures because the HEXAGON_FEATURES_FOR_CORRECT_FIXED_LENGTH_VECTOR_ABI array only had entries for vectors up to 1024 bits. This caused the ABI checker to emit "unsupported vector type" errors for 2048-bit HvxVectorPair (used in 128-byte HVX mode).

Add 2048 byte entry to allow HvxVectorPair to be passed in extern "C" funcs when the hvx-length128b is enabled.

Previously, rustc rejected HvxVectorPair types in function signatures
because the HEXAGON_FEATURES_FOR_CORRECT_FIXED_LENGTH_VECTOR_ABI array
only had entries for vectors up to 1024 bits. This caused the ABI checker
to emit "unsupported vector type" errors for 2048-bit HvxVectorPair
(used in 128-byte HVX mode).

Add 2048 byte entry to allow HvxVectorPair to be passed
in extern "C" funcs when the hvx-length128b is enabled.
@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Feb 12, 2026
@rustbot
Copy link
Collaborator

rustbot commented Feb 12, 2026

r? @madsmtm

rustbot has assigned @madsmtm.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: compiler
  • compiler expanded to 68 candidates
  • Random selection from 17 candidates

&[(512, "hvx-length64b"), (1024, "hvx-length128b")];
const HEXAGON_FEATURES_FOR_CORRECT_FIXED_LENGTH_VECTOR_ABI: &'static [(u64, &'static str)] = &[
(512, "hvx-length64b"), // HvxVector in 64-byte mode
(1024, "hvx-length128b"), // HvxVector in 128-byte mode, or HvxVectorPair in 64-byte mode
Copy link
Contributor

Choose a reason for hiding this comment

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

Am I correctly understanding that a 1024-bit HvxVectorPair would actually require the hvx-length64b feature (and that the check is overly conservative here)?

Copy link
Contributor

Choose a reason for hiding this comment

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

It actually sounds like the real problem is the check itself, features_for_correct_fixed_length_vector_abi changes depending on PassMode::Pair or PassMode::Direct?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It actually sounds like the real problem is the check itself, features_for_correct_fixed_length_vector_abi changes depending on PassMode::Pair or PassMode::Direct?

Hmm good point let me take a closer look.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I could do this...

const HEXAGON_FEATURES_FOR_CORRECT_FIXED_LENGTH_VECTOR_ABI: &'static [(u64, &'static str)] = &[
    (512, "hvx-length64b"),
    (1024, "hvx"),           // hvx is implied by both length modes
    (2048, "hvx-length128b"),
];

... I don't love it though. Not the clearest error message.

I wonder if I could specialize like so

fn check_vector_abi_feature(&self, size_bits: u64, have_feature: impl Fn(&str) -> bool) -> Result<(), 
&'static str> {
    match size_bits {
        0..=512 => {
            if have_feature("hvx-length64b") { Ok(()) }
            else { Err("hvx-length64b") }
        }
        513..=1024 => {
            if have_feature("hvx-length64b") || have_feature("hvx-length128b") { Ok(()) }
            else { Err("hvx-length64b or hvx-length128b") }
        }
        1025..=2048 => {
            if have_feature("hvx-length128b") { Ok(()) }
            else { Err("hvx-length128b") }
        }
        _ => Err("unsupported vector size")
    }
}

Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm, I'm not sure. I think your proposed solution would accept in a sense "too many" ABIs, would it not? E.g. passing a 1024-bit HvxVector with only the "hvx-length64b" feature enabled should fail in a correct implementation (if I'm understanding right)?


Kinda odd though that all of this isn't a problem on other architectures, do you understand why that is? Is there something special about Hexagon's pair vectors and feature flags here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think other architectures' target features are cumulative - +newest-whizbang implies +slightly-older-whizbang and that in turn implies +older-still-whizbang. HVX 64 byte mode and 128 byte mode are mutually exclusive. So now we have ambiguity if we're trying to map a size to a feature. 1024 bit values could either be a single 128 byte register in hvx-length128b and a 128-byte regpair in hvx-length64b. Both of these imply hvx but none of these imply the other lengths.

I don't know how the PassMode works yet - I don't think the HvxVectorPair would use PassMode::Pair but I will do some digging to try and figure it out.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah, I didn't get that they were incompatible. Must at least one of them be set? If so, then I'd lean towards (1024, "hvx"),.

I don't think the HvxVectorPair would use PassMode::Pair but I will do some digging to try and figure it out.

Oh, okay.

@madsmtm
Copy link
Contributor

madsmtm commented Feb 12, 2026

Not familiar with Hexagon, but this looks correct enough, and you're the target maintainer, so:
@bors r+ rollup

@rust-bors
Copy link
Contributor

rust-bors bot commented Feb 12, 2026

📌 Commit eb1e411 has been approved by madsmtm

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 Feb 12, 2026
@madsmtm madsmtm added the O-hexagon-unknown-qurt Target: hexagon-unknown-qurt label Feb 12, 2026
Zalathar added a commit to Zalathar/rust that referenced this pull request Feb 13, 2026
…=madsmtm

Add 2048-bit HvxVectorPair support to Hexagon SIMD ABI checks

Previously, rustc rejected HvxVectorPair types in function signatures because the HEXAGON_FEATURES_FOR_CORRECT_FIXED_LENGTH_VECTOR_ABI array only had entries for vectors up to 1024 bits. This caused the ABI checker to emit "unsupported vector type" errors for 2048-bit HvxVectorPair (used in 128-byte HVX mode).

Add 2048 byte entry to allow HvxVectorPair to be passed in extern "C" funcs when the hvx-length128b is enabled.
rust-bors bot pushed a commit that referenced this pull request Feb 13, 2026
Rollup of 18 pull requests

Successful merges:

 - #150551 (Compute localized outlives constraints lazily)
 - #150752 (Update libc to v0.2.181)
 - #150988 (Improve code suggestion for incorrect macro_rules! usage)
 - #152422 (Change query proc macro to be more rust-analyzer friendly)
 - #152496 (Fix multi-cgu+debug builds using autodiff by delaying autodiff till lto)
 - #152514 (Collect active query jobs into struct `QueryJobMap`)
 - #152520 (Don't use `DepContext` in `rustc_middle::traits::cache`)
 - #152528 (Support serializing CodegenContext)
 - #152082 (Move tests)
 - #152232 (Add must_use for FileTimes)
 - #152329 (Simplify parallel! macro)
 - #152444 (`-Znext-solver` Prevent committing unfulfilled unsized coercion)
 - #152486 (remove redundant backchain attribute in codegen)
 - #152519 (Fix feature gating for new `try bikeshed` expressions)
 - #152529 (sparc64: enable abi compatibility test)
 - #152548 (reject inline const patterns pre-expansion)
 - #152550 (Port #[prelude_import] to the attribute parser)
 - #152552 (Add 2048-bit HvxVectorPair support to Hexagon SIMD ABI checks)
Zalathar added a commit to Zalathar/rust that referenced this pull request Feb 13, 2026
…=madsmtm

Add 2048-bit HvxVectorPair support to Hexagon SIMD ABI checks

Previously, rustc rejected HvxVectorPair types in function signatures because the HEXAGON_FEATURES_FOR_CORRECT_FIXED_LENGTH_VECTOR_ABI array only had entries for vectors up to 1024 bits. This caused the ABI checker to emit "unsupported vector type" errors for 2048-bit HvxVectorPair (used in 128-byte HVX mode).

Add 2048 byte entry to allow HvxVectorPair to be passed in extern "C" funcs when the hvx-length128b is enabled.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

O-hexagon-unknown-qurt Target: hexagon-unknown-qurt 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