Skip to content
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

#[repr(simd)] struct(isize, isize) not allowed #2513

Closed
gnzlbg opened this issue Aug 3, 2018 · 3 comments
Closed

#[repr(simd)] struct(isize, isize) not allowed #2513

gnzlbg opened this issue Aug 3, 2018 · 3 comments
Labels
T-lang Relevant to the language team, which will review and decide on the RFC.

Comments

@gnzlbg
Copy link
Contributor

gnzlbg commented Aug 3, 2018

Repro (playground: https://play.rust-lang.org/?gist=efa6e5caf752ccca651014ae5009feb8&version=nightly&mode=debug&edition=2015):

#![feature(repr_simd)] 

#[repr(simd)] struct A(isize, isize); // ERROR

#[cfg(target_pointer_width = "64")]
type isize_ = i64;

#[cfg(target_pointer_width = "32")]
type isize_ = i32;

#[repr(simd)] struct B(isize_, isize_); // Q: Is this ok?

produces

error[E0077]: SIMD vector element type should be machine type
 --> src/main.rs:3:15
  |
3 | #[repr(simd)] struct A(isize, isize);
  |               ^^^^^^^^^^^^^^^^^^^^^^^

error: aborting due to previous error

I am wondering why aren't isize and usize allowed ? I currently work around this to implement simd vectors of pointers, but maybe that's broken for reason I don't understand?

@eaglgenes101
Copy link

eaglgenes101 commented Aug 7, 2018

I think this can be made a thing (size type variables are just differences in memory addresses under the hood, after all), but the better question is if it should. In particular, what are the use cases of performing bulk arithmetic operations on structs of size types?

@gnzlbg
Copy link
Contributor Author

gnzlbg commented Aug 7, 2018

what are the use cases of performing bulk arithmetic operations on size type structs?

The same as for normal pointers:

// vector of pointers
#[repr(simd)] struct x2<T>(T, T);
type const_ptr_x2 = x2<*const T>;
let a = const_ptr_x2(...);
let b = const_ptr_x2(...);

let c: ??? = a - b;  /// ??? should be a vector of isize

let d: ??? = ???(...); // wrapping_add takes a vector of usize
let e = a.wrapping_add(d);

@Centril Centril added the T-lang Relevant to the language team, which will review and decide on the RFC. label Oct 14, 2018
@Centril
Copy link
Contributor

Centril commented Oct 15, 2018

Closing in favor of rust-lang/rust#55078.

@Centril Centril closed this as completed Oct 15, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T-lang Relevant to the language team, which will review and decide on the RFC.
Projects
None yet
Development

No branches or pull requests

3 participants