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

rustc: Add #[rustc_args_required_const] #48018

Merged
merged 1 commit into from
Feb 7, 2018

Conversation

alexcrichton
Copy link
Member

This commit adds a new unstable attribute to the compiler which requires that
arguments to a function are always provided as constants. The primary use case
for this is SIMD intrinsics where arguments are defined by vendors to be
constant and in LLVM they indeed must be constant as well.

For now this is mostly just a semantic guarantee in rustc that an argument is a
constant when invoked, phases like trans don't actually take advantage of it
yet. This means that we'll be able to use this in stdsimd but we won't be able
to remove the constify_* macros just yet. Hopefully soon though!

@rust-highfive
Copy link
Collaborator

r? @pnkfelix

(rust_highfive has picked a reviewer for you, use r? to override)

@alexcrichton
Copy link
Member Author

r? @eddyb

@rust-highfive rust-highfive assigned eddyb and unassigned pnkfelix Feb 5, 2018
@@ -73,7 +73,7 @@ pub enum Candidate {

/// Array of indices found in the third argument of
/// a call to one of the simd_shuffleN intrinsics.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should also update the comment.

let terminator = mir[bb].terminator();
let ty = match terminator.kind {
TerminatorKind::Call { ref args, .. } => {
args[2].ty(mir, tcx)
args[index].ty(mir, tcx)
}
_ => {
span_bug!(terminator.source_info.span,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also the ICE message here.

This commit adds a new unstable attribute to the compiler which requires that
arguments to a function are always provided as constants. The primary use case
for this is SIMD intrinsics where arguments are defined by vendors to be
constant and in LLVM they indeed must be constant as well.

For now this is mostly just a semantic guarantee in rustc that an argument is a
constant when invoked, phases like trans don't actually take advantage of it
yet. This means that we'll be able to use this in stdsimd but we won't be able
to remove the `constify_*` macros just yet. Hopefully soon though!
@alexcrichton
Copy link
Member Author

@bors: r=eddyb

@bors
Copy link
Contributor

bors commented Feb 5, 2018

📌 Commit 27a4e73 has been approved by eddyb

@pietroalbini pietroalbini added the S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. label Feb 5, 2018
@varkor
Copy link
Member

varkor commented Feb 6, 2018

Out of curiosity, is there a reason you decided to use argument indices rather than names, which would appear to me to be more readable and harder to get wrong?

@eddyb
Copy link
Member

eddyb commented Feb 6, 2018

@varkor Names come from pattern-matching bindings, arguments don't (necessarily) have them.

Manishearth added a commit to Manishearth/rust that referenced this pull request Feb 7, 2018
…ddyb

rustc: Add `#[rustc_args_required_const]`

This commit adds a new unstable attribute to the compiler which requires that
arguments to a function are always provided as constants. The primary use case
for this is SIMD intrinsics where arguments are defined by vendors to be
constant and in LLVM they indeed must be constant as well.

For now this is mostly just a semantic guarantee in rustc that an argument is a
constant when invoked, phases like trans don't actually take advantage of it
yet. This means that we'll be able to use this in stdsimd but we won't be able
to remove the `constify_*` macros just yet. Hopefully soon though!
bors added a commit that referenced this pull request Feb 7, 2018
Rollup of 10 pull requests

- Successful merges: #47613, #47631, #47810, #47883, #47922, #47944, #48014, #48018, #48020, #48028
- Failed merges:
@bors bors merged commit 27a4e73 into rust-lang:master Feb 7, 2018
@alexcrichton alexcrichton deleted the require-const-arg branch February 26, 2018 23:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants