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 for a scalable simd representation #118917
Draft
JamieCunliffe
wants to merge
10
commits into
rust-lang:master
Choose a base branch
from
JamieCunliffe:sve
base: master
Could not load branches
Branch not found: {{ refName }}
Could not load tags
Nothing to show
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+674
−93
Draft
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
ea49987
Prototype of scalable vectors
JamieCunliffe 1d5a32f
Add feature gate for Scalable SIMD types
JamieCunliffe 7b7b4a4
Fix incorrect type representation in test.
JamieCunliffe 949b1a8
Return Err in homogeneous_aggregate rather than lie about the Size.
JamieCunliffe cf3864a
Restrict the spilling of scalable types to the problematic ones.
JamieCunliffe 6321f69
Scalable SIMD tests for disallowing scalable types in types.
JamieCunliffe ae1aac0
Allow SVE types to be taken by reference.
JamieCunliffe 17a06d9
Add ?Sized bound to some SIMD intrinsics.
JamieCunliffe 351bec3
Don't require the user to enable the unsized features.
JamieCunliffe a371ac9
Fix up style review comments.
JamieCunliffe File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -389,6 +389,14 @@ impl<'ll, 'tcx> IntrinsicCallMethods<'tcx> for Builder<'_, 'll, 'tcx> { | |
let use_integer_compare = match layout.abi() { | ||
Scalar(_) | ScalarPair(_, _) => true, | ||
Uninhabited | Vector { .. } => false, | ||
ScalableVector { .. } => { | ||
tcx.dcx().emit_err(InvalidMonomorphization::NonScalableType { | ||
span, | ||
name: sym::raw_eq, | ||
ty: tp_ty, | ||
}); | ||
return Ok(()); | ||
} | ||
Aggregate { .. } => { | ||
// For rusty ABIs, small aggregates are actually passed | ||
// as `RegKind::Integer` (see `FnAbi::adjust_for_abi`), | ||
|
@@ -1084,6 +1092,18 @@ fn generic_simd_intrinsic<'ll, 'tcx>( | |
return Ok(bx.select(m_i1s, args[1].immediate(), args[2].immediate())); | ||
} | ||
|
||
if name == sym::simd_reinterpret { | ||
require_simd!(ret_ty, SimdReturn); | ||
|
||
return Ok(match args[0].val { | ||
OperandValue::Ref(val, _, _) | OperandValue::Immediate(val) => { | ||
bx.bitcast(val, llret_ty) | ||
} | ||
OperandValue::ZeroSized => bx.const_undef(llret_ty), | ||
OperandValue::Pair(_, _) => todo!(), | ||
}); | ||
} | ||
|
||
// every intrinsic below takes a SIMD vector as its first argument | ||
let (in_len, in_elem) = require_simd!(arg_tys[0], SimdInput); | ||
let in_ty = arg_tys[0]; | ||
|
@@ -1296,12 +1316,17 @@ fn generic_simd_intrinsic<'ll, 'tcx>( | |
InvalidMonomorphization::MismatchedLengths { span, name, m_len, v_len } | ||
); | ||
match m_elem_ty.kind() { | ||
ty::Int(_) => {} | ||
// Arm SVE has a svbool type and we need to represent that as a bool in the type system. | ||
ty::Int(_) | ty::Bool => {} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could use a comment explaining this is for |
||
_ => return_error!(InvalidMonomorphization::MaskType { span, name, ty: m_elem_ty }), | ||
} | ||
// truncate the mask to a vector of i1s | ||
let i1 = bx.type_i1(); | ||
let i1xn = bx.type_vector(i1, m_len as u64); | ||
let i1xn = if arg_tys[1].is_scalable_simd() { | ||
bx.type_scalable_vector(i1, m_len as u64) | ||
} else { | ||
bx.type_vector(i1, m_len as u64) | ||
}; | ||
let m_i1s = bx.trunc(args[0].immediate(), i1xn); | ||
return Ok(bx.select(m_i1s, args[1].immediate(), args[2].immediate())); | ||
} | ||
|
@@ -2271,6 +2296,7 @@ fn generic_simd_intrinsic<'ll, 'tcx>( | |
out_elem | ||
}); | ||
} | ||
|
||
macro_rules! arith_binary { | ||
($($name: ident: $($($p: ident),* => $call: ident),*;)*) => { | ||
$(if name == sym::$name { | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Could use a comment.