-
-
Notifications
You must be signed in to change notification settings - Fork 14.5k
Add 2048-bit HvxVectorPair support to Hexagon SIMD ABI checks #152552
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
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.
|
r? @madsmtm rustbot has assigned @madsmtm. Use Why was this reviewer chosen?The reviewer was selected based on:
|
| &[(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 |
There was a problem hiding this comment.
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)?
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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_abichanges depending onPassMode::PairorPassMode::Direct?
Hmm good point let me take a closer look.
There was a problem hiding this comment.
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")
}
}There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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::Pairbut I will do some digging to try and figure it out.
Oh, okay.
|
Not familiar with Hexagon, but this looks correct enough, and you're the target maintainer, so: |
…=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.
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)
…=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.
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.