-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Allow SIMD types in generics. Closes #10604 #11717
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
Conversation
@@ -424,19 +425,22 @@ fn generic_type_of(cx: &CrateContext, r: &Repr, name: Option<&str>, sizing: bool | |||
let align = most_aligned.align; | |||
let discr_ty = ll_inttype(cx, ity); | |||
let discr_size = machine::llsize_of_alloc(cx, discr_ty) as u64; | |||
let align_units = (size + align - 1) / align - 1; |
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.
What happens if size == n * align
? Doesn't this give n - 1
? (Is this correct?)
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 would be (n * align - 1) / align
. Either way, all that was changed was I moved that line from 435 to 428 and added the minus one from 439. That was so I could use it in the match arms.
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 is n - 1
, which is right — this patch also changes align_units
from being the size of the entire object to the size of the padding.
cc @jdm, I think you're quite familiar with the adt module |
cc @sanxiyn too |
Looks good to me. |
// option. This file may not be copied, modified, or distributed | ||
// except according to those terms. | ||
|
||
fn main() { |
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 will need to be pub fn main
to pass the check-fast
target on windows.
Updated the tests based on your comments, @alexcrichton; barring other issues, this PR should be good to go. |
Ah, I forgot, but these need an |
Ah kk, I was greatly confused. |
Both need |
Updated both to include |
Note that it still doesn't allow generic types to be marked with #[simd].
Note that it still doesn't allow generic types to be marked with #[simd].