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

Add reference for asm-goto #1693

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

nbdd0121
Copy link
Contributor

@nbdd0121 nbdd0121 commented Dec 4, 2024

The asm-goto-with-outputs is still unstable, so in the reference it's still mentioned as forbidden by a check rule.

Stabilization PR: rust-lang/rust#133870

@ehuss ehuss added S-waiting-on-stabilization Waiting for a stabilization PR to be merged in the main Rust repository S-waiting-on-review Status: The marked PR is awaiting review from a maintainer labels Dec 5, 2024
@traviscross
Copy link
Contributor

@Amanieu: What do you think?

src/inline-assembly.md Outdated Show resolved Hide resolved
src/inline-assembly.md Outdated Show resolved Hide resolved
@ehuss
Copy link
Contributor

ehuss commented Dec 12, 2024

@rustbot author

@rustbot rustbot added S-waiting-on-author Status: The marked PR is awaiting some action (such as code changes) from the PR author. and removed S-waiting-on-review Status: The marked PR is awaiting review from a maintainer labels Dec 12, 2024
@traviscross
Copy link
Contributor

We reviewed this in the lang call today. Everyone read through it. It looked right. Nobody had any notes.

The asm-goto-with-outputs is still unstable, so in the reference it's
still mentioned as forbidden by a check rule.
@@ -180,6 +180,13 @@ r[asm.operand-type.supported-operands.sym]
- The type of the expression may be any integer type, but defaults to `i32` just like integer literals.
- The value of the expression is formatted as a string and substituted directly into the asm template string.

r[asm.operand-type.supported-operands.label]
* `label <block>`
- The address of the block is substituted into the asm template string. The assembly block may jump to the substituted addresses.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
- The address of the block is substituted into the asm template string. The assembly block may jump to the substituted addresses.
- The address of the block is substituted into the asm template string. The assembly block may jump to the substituted address.

- The address of the block is substituted into the asm template string. The assembly block may jump to the substituted addresses.
- After execution of the block, the `asm!` expression returns.
- The type of the block must be unit or `!` (never).
- The block starts new safety context; despite the outer `unsafe` needed for `asm!`, you need an extra `unsafe` to perform unsafe operations inside the block.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
- The block starts new safety context; despite the outer `unsafe` needed for `asm!`, you need an extra `unsafe` to perform unsafe operations inside the block.
- The block starts a new safety context; despite the outer `unsafe` block needed for `asm!`, unsafe operations within the `label` block must be wrapped in an inner `unsafe` block.

@@ -553,6 +560,8 @@ r[asm.options.supported-options.noreturn]
- `noreturn`: The `asm!` block never returns, and its return type is defined as `!` (never).
Behavior is undefined if execution falls through past the end of the asm code.
A `noreturn` asm block behaves just like a function which doesn't return; notably, local variables in scope are not dropped before it is invoked.
- When labels are present, `noreturn` means the execution of the `asm!` block never falls through; the asm block may only exit by jumping to one of the specified blocks.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
- When labels are present, `noreturn` means the execution of the `asm!` block never falls through; the asm block may only exit by jumping to one of the specified blocks.
- When one or more `label` blocks are present, `noreturn` means the execution of the `asm!` block never falls through; the asm block may only exit by jumping to one of the specified blocks.

@@ -553,6 +560,8 @@ r[asm.options.supported-options.noreturn]
- `noreturn`: The `asm!` block never returns, and its return type is defined as `!` (never).
Behavior is undefined if execution falls through past the end of the asm code.
A `noreturn` asm block behaves just like a function which doesn't return; notably, local variables in scope are not dropped before it is invoked.
- When labels are present, `noreturn` means the execution of the `asm!` block never falls through; the asm block may only exit by jumping to one of the specified blocks.
The entire `asm!` block will have unit type in this case, unless all label blocks diverge, in which case the return type is `!`.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
The entire `asm!` block will have unit type in this case, unless all label blocks diverge, in which case the return type is `!`.
The entire `asm!` block will have unit type in this case, unless all `label` blocks diverge, in which case the return type is `!`.

@@ -576,7 +585,10 @@ r[asm.options.checks.pure]
- It is a compile-time error to specify `pure` on an asm block with no outputs or only discarded outputs (`_`).

r[asm.options.checks.noreturn]
- It is a compile-time error to specify `noreturn` on an asm block with outputs.
- It is a compile-time error to specify `noreturn` on an asm block with outputs and without labels.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
- It is a compile-time error to specify `noreturn` on an asm block with outputs and without labels.
- It is a compile-time error to specify `noreturn` on an asm block with outputs.

If it's a compile-time error to have a label block on an asm block with outputs (as below), then whether it's a compile-time error to specify noreturn on an asm block with outputs is invariant to whether there are labels, no?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This change is to make r[asm.options.checks.label-with-outputs] be the only thing that blocks the asm-goto-with-outputs feature.

- It is a compile-time error to specify `noreturn` on an asm block with outputs and without labels.

r[asm.options.checks.label-with-outputs]
- It is a compile-time error to specify label on an asm block with outputs.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
- It is a compile-time error to specify label on an asm block with outputs.
- It is a compile-time error to have a `label` block on an asm block with outputs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-author Status: The marked PR is awaiting some action (such as code changes) from the PR author. S-waiting-on-stabilization Waiting for a stabilization PR to be merged in the main Rust repository
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants