-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Support input/output in vector registers of s390x inline assembly (under asm_experimental_reg feature) #131664
Conversation
☔ The latest upstream changes (presumably #131672) made this pull request unmergeable. Please resolve the merge conflicts. |
107fef5
to
57419c1
Compare
☔ The latest upstream changes (presumably #132152) made this pull request unmergeable. Please resolve the merge conflicts. |
☔ The latest upstream changes (presumably #133006) made this pull request unmergeable. Please resolve the merge conflicts. |
57419c1
to
a9476db
Compare
Some changes occurred in compiler/rustc_codegen_gcc |
a9476db
to
d0a124a
Compare
d0a124a
to
51506f9
Compare
51506f9
to
b6b9f79
Compare
b6b9f79
to
2c8f6de
Compare
Is there a way to feature-gate this functionality? Since s390x asm support is stable, every change here needs to go through an FCP since it will instantly be stable. |
Yes, I implemented it in another branch (taiki-e/rust@s390x-asm-vreg-inout...s390x-asm-vreg-inout-unstable):
Here I'm using the existing asm_experimental_arch as a gate, but it might make more sense to add a dedicated gate such as asm_experimental_reg. |
Some changes occurred in compiler/rustc_codegen_cranelift cc @bjorn3 |
Added new asm_experimental_reg feature (tracking issue: #133416) and moved s390x non-clobber-only vector register support under that feature.
|
This comment has been minimized.
This comment has been minimized.
d2357fb
to
9b0b4c8
Compare
let reg_size = | ||
reg_class.supported_types(self.arch).iter().map(|(ty, _)| ty.size()).max().unwrap(); | ||
let reg_size = reg_class | ||
.supported_types(self.arch, self.allow_experimental_reg) |
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.
At the codegen stage we can just use true
here instead of allowed_experimental_reg
. All the stability checking will have been done in priot stages.
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.
Changed rustc_codegen_* to just use true.
I also left a document about the cases in which it is fine to always pass true.
rust/compiler/rustc_target/src/asm/mod.rs
Lines 608 to 610 in c024d8c
/// At the codegen stage, it is fine to always pass true for `allow_experimental_reg`, | |
/// since all the stability checking will have been done in prior stages. | |
pub fn supported_types( |
let reg_class = reg.reg_class(); | ||
let supported_tys = reg_class.supported_types(asm_arch); | ||
let supported_tys = reg_class.supported_types(asm_arch, allow_experimental_reg); | ||
let Some((_, feature)) = supported_tys.iter().find(|&&(t, _)| t == asm_ty) else { |
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.
This also needs to handle the case where a given type is only supported with allow_experimental_reg and report an appropriate error message. This would be used in the future for SVE support for example since it adds more types to an existing register class.
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.
Done.
rust/tests/ui/feature-gates/feature-gate-asm_experimental_reg.stderr
Lines 11 to 19 in c024d8c
error[E0658]: type `i32` cannot be used with this register class in stable | |
--> $DIR/feature-gate-asm_experimental_reg.rs:20:23 | |
| | |
LL | asm!("", in("v0") 0); | |
| ^ | |
| | |
= note: see issue #133416 <https://github.com/rust-lang/rust/issues/133416> for more information | |
= help: add `#![feature(asm_experimental_reg)]` to the crate attributes to enable | |
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date |
9b0b4c8
to
7bd6de8
Compare
This comment has been minimized.
This comment has been minimized.
7bd6de8
to
c024d8c
Compare
@bors r+ |
…iaskrgr Rollup of 8 pull requests Successful merges: - rust-lang#131523 (Fix asm goto with outputs and move it to a separate feature gate) - rust-lang#131664 (Support input/output in vector registers of s390x inline assembly (under asm_experimental_reg feature)) - rust-lang#132432 (Add a test to verify that libstd doesn't use protected symbols) - rust-lang#132502 (Document possibility to set core features in example config.toml) - rust-lang#132529 (ci(triagebot): add more top-level files to A-meta) - rust-lang#132533 (Add BorrowedBuf::into_filled{,_mut} methods to allow returning buffer with original lifetime) - rust-lang#132803 (Fix broken url) - rust-lang#132982 (alloc: fix `Allocator` method names in `alloc` free function docs) r? `@ghost` `@rustbot` modify labels: rollup
Rollup merge of rust-lang#131664 - taiki-e:s390x-asm-vreg-inout, r=Amanieu Support input/output in vector registers of s390x inline assembly (under asm_experimental_reg feature) This extends currently clobber-only vector registers (`vreg`) support to allow passing `#[repr(simd)]` types, floats (f32/f64/f128), and integers (i32/i64/i128) as input/output. This is unstable and gated under new `#![feature(asm_experimental_reg)]` (tracking issue: rust-lang#133416). If the feature is not enabled, only clober is supported as before. | Architecture | Register class | Target feature | Allowed types | | ------------ | -------------- | -------------- | -------------- | | s390x | `vreg` | `vector` | `i32`, `f32`, `i64`, `f64`, `i128`, `f128`, `i8x16`, `i16x8`, `i32x4`, `i64x2`, `f32x4`, `f64x2` | This matches the list of types that are supported by the vector registers in LLVM: https://github.com/llvm/llvm-project/blob/llvmorg-19.1.0/llvm/lib/Target/SystemZ/SystemZRegisterInfo.td#L301-L313 In addition to `core::simd` types and floats listed above, custom `#[repr(simd)]` types of the same size and type are also allowed. All allowed types other than i32/f32/i64/f64/i128, and relevant target features are currently unstable. Currently there is no SIMD type for s390x in `core::arch`, but this is tracked in rust-lang#130869. cc rust-lang#130869 about vector facility support in s390x cc rust-lang#125398 & rust-lang#116909 about f128 support in asm `@rustbot` label +O-SystemZ +A-inline-assembly
…anieu Support input/output in vector registers of s390x inline assembly (under asm_experimental_reg feature) This extends currently clobber-only vector registers (`vreg`) support to allow passing `#[repr(simd)]` types, floats (f32/f64/f128), and integers (i32/i64/i128) as input/output. This is unstable and gated under new `#![feature(asm_experimental_reg)]` (tracking issue: rust-lang#133416). If the feature is not enabled, only clober is supported as before. | Architecture | Register class | Target feature | Allowed types | | ------------ | -------------- | -------------- | -------------- | | s390x | `vreg` | `vector` | `i32`, `f32`, `i64`, `f64`, `i128`, `f128`, `i8x16`, `i16x8`, `i32x4`, `i64x2`, `f32x4`, `f64x2` | This matches the list of types that are supported by the vector registers in LLVM: https://github.com/llvm/llvm-project/blob/llvmorg-19.1.0/llvm/lib/Target/SystemZ/SystemZRegisterInfo.td#L301-L313 In addition to `core::simd` types and floats listed above, custom `#[repr(simd)]` types of the same size and type are also allowed. All allowed types other than i32/f32/i64/f64/i128, and relevant target features are currently unstable. Currently there is no SIMD type for s390x in `core::arch`, but this is tracked in rust-lang#130869. cc rust-lang#130869 about vector facility support in s390x cc rust-lang#125398 & rust-lang#116909 about f128 support in asm `@rustbot` label +O-SystemZ +A-inline-assembly
This extends currently clobber-only vector registers (
vreg
) support to allow passing#[repr(simd)]
types, floats (f32/f64/f128), and integers (i32/i64/i128) as input/output.This is unstable and gated under new
#![feature(asm_experimental_reg)]
(tracking issue: #133416). If the feature is not enabled, only clober is supported as before.vreg
vector
i32
,f32
,i64
,f64
,i128
,f128
,i8x16
,i16x8
,i32x4
,i64x2
,f32x4
,f64x2
This matches the list of types that are supported by the vector registers in LLVM:
https://github.com/llvm/llvm-project/blob/llvmorg-19.1.0/llvm/lib/Target/SystemZ/SystemZRegisterInfo.td#L301-L313
In addition to
core::simd
types and floats listed above, custom#[repr(simd)]
types of the same size and type are also allowed. All allowed types other than i32/f32/i64/f64/i128, and relevant target features are currently unstable.Currently there is no SIMD type for s390x in
core::arch
, but this is tracked in #130869.cc #130869 about vector facility support in s390x
cc #125398 & #116909 about f128 support in asm
@rustbot label +O-SystemZ +A-inline-assembly